Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:10:12+00:00 2026-06-15T14:10:12+00:00

I am working on very complex and dynamic form where I do lot of

  • 0

I am working on very complex and dynamic form where I do lot of calls to various methods to render partials depending upon values chosen for drop downs using jQuery. Problem is that after filling the form if it fails validation the form loses all the filled in values upon re-load. I got around this by sending some specific values from params{} hash to methods for my partials on re-load. But it is very cumbersome and I have large number of elements in params hash. How can send the whole params{} to another method in the same controller using jQuery?

Ok I tried this in my form:

$.post("/collections/show_selected_media_fields",{media_type: $("#collections_controller_ev0_media_id option:selected").text(), parent_form_action: "<%=params[:action]%>",ev0_manufacturer_id:"<%=params[:collections_controller_ev0].inspect%>", }, function(data) {$("#show_selected_media_fields").html(data);}); 

It produces following string sent as parameter:

  Parameters: {"ev0_manufacturer_id"=>"{&quot;client_asset_id&quot;=&gt;&quot;&quot;, &quot;status_id&quot;=&gt;&quot;6&quot;, &quot;server_
name&quot;=&gt;&quot;&quot;, &quot;media_id&quot;=&gt;&quot;11&quot;, &quot;serial_number&quot;=&gt;&quot;&quot;, &quot;evidence_number&quot
;=&gt;&quot;qwe&quot;, &quot;notes&quot;=&gt;&quot;&quot;, &quot;model&quot;=&gt;&quot;&quot;, &quot;manufacturer_id&quot;=&gt;&quot;69&quot
;, &quot;interface&quot;=&gt;&quot;SATA&quot;, &quot;obtained_from&quot;=&gt;&quot;wr&quot;, &quot;evidence_type_id&quot;=&gt;&quot;1&quot;}
", "media_type"=>"Server", "parent_form_action"=>"quick_save"}

how can I convert this raw string to a hash in controller?

{&quot;client_asset_id&quot;=&gt; 

needs to be converted to

{"client_asset_id"=>"",... etc}

===========

ok I tried Tom’s method. That produces the params as a string in the following shape. I tried to convert it into hash by doing an eval on it. But it errors out.

{commit=>Save, ev1_current_location_id=>, collections_controller_ev1=>{file_system=>NTFS, obtained_from=>, evidence_number=>, interface=>SAT
A, size_unit=>GB, manufacturer_id=>, encryption_version=>, media_id=>3, size=>, evidence_type_id=>3, other_encryption=>, encryption_method=>
N/A, serial_number=>, model=>, encryption_key=>}, ev0_from_location_category=>, ev0_obtained_from_email_id=>, collections_controller_ev0=>{o
btained_from=>, evidence_number=>, media_id=>1, evidence_type_id=>1, status_id=>6}, custody_action=>Create, collection=>{acquired_by=>Amande
ep Singh, custodian_id=>12, matter_id=>58, location=>sa Nose, client_id=>11, software_version=>, collection_date_time=>Fri Nov 30 14:28:06 -
0800 2012, acquisition_method=>Direct Collection, notes=>, software_id=>1}, _method=>put, utf8=>Γ£ô, ev1_current_location_category=>, ev0_cu
rrent_location_category=>, add_working_copy=>No, ev1_obtained_from_email_id=>, authenticity_token=>3vyn6057DDIyfgTnbckeh5heRTIgcVBfxtY89Krfr
/c=, ev1_existing_artifact_type=>, ev0_from_location_id=>, action=>quick_save, ev1_from_location_id=>, ev1_from_location_category=>, ev0_cur
rent_location_id=>, controller=>collections}

using .to_json and HTMLEntities gem I have gotten to a point where I have the following string. I need to convert it back to params hash. How to?

{"utf8"=>"Γ£ô","collection"=>{"acquired_by"=>"Amandeep Singh","notes"=>"","matter_id"=>"58","software_id"=>"1","acquisition_method"=>"Direct
 Collection","client_id"=>"11","custodian_id"=>"0","collection_date_time"=>"Fri Nov 30 15=>52=>12 -0800 2012","software_version"=>"","locati
on"=>"sa Nose"},"ev0_current_location_id"=>"","ev1_existing_artifact_type"=>"","ev1_obtained_from_email_id"=>"","custody_action"=>"Create","
action"=>"quick_save","ev0_current_location_category"=>"","ev1_from_location_category"=>"","_method"=>"put","ev0_obtained_from_email_id"=>""
,"ev0_from_location_category"=>"","ev1_current_location_category"=>"","commit"=>"Save","controller"=>"collections","authenticity_token"=>"3v
yn6057DDIyfgTnbckeh5heRTIgcVBfxtY89Krfr/c=","ev0_from_location_id"=>"","ev1_current_location_id"=>"","collections_controller_ev0"=>{"status_
id"=>"6","media_id"=>"9","obtained_from"=>"","evidence_number"=>"","evidence_type_id"=>"1"},"collections_controller_ev1"=>{"media_id"=>"3","
encryption_key"=>"","encryption_version"=>"","size"=>"","obtained_from"=>"","encryption_method"=>"N/A","model"=>"","evidence_number"=>"","ev
idence_type_id"=>"3","size_unit"=>"GB","other_encryption"=>"","interface"=>"SATA","file_system"=>"NTFS","serial_number"=>"","manufacturer_id
"=>""},"ev1_from_location_id"=>"","add_working_copy"=>"No"}

========== edit==========

I am using the following in my view.

JSON( params[:collections_controller_ev0])

It sends following quoted string to my controller.

{&quot;evidence_number&quot;:&quot;&quot;,&quot;notes&quot;:&quot;&quot;,&quot;size&quot;:&quot;&quot;,&quot;model&quot;:&quot;&quot;,&quot;evidence_type_id&quot;:&quot;1&quot;,&quot;media_id&quot;:&quot;1&quot;,&quot;obtained_from&quot;:&quot;&quot;,&quot;status_id&quot;:&quot;6&quot;,&quot;manufacturer_id&quot;:&quot;&quot;,&quot;size_unit&quot;:&quot;GB&quot;}

I convert it into valid JSON string as below using gsub(‘"’,'”‘). The output is a VALID JSON string as validated by http://jsonlint.com/ shown below.

{"evidence_number":"","notes":"123","size":"123","model":"123","evidence_type_id":"1","media_id":"1","obtained_from":"","status_id":"6","manufacturer_id":"69","size_unit":"GB"}

JSON.parse works without error on this string but does not produce a properly formed hash. It produces following:

notes123evidence_numbersize123model123evidence_type_id1media_id1obtained_fromstatus_id6size_unitGBmanufacturer_id69

Can someone please tell me how to correct this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:10:13+00:00Added an answer on June 15, 2026 at 2:10 pm

    The method showed in my last edit works! it produces correct hash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Because I'm working with a very complex table with nasty repeated values in variable
I'm working on my first very complex JQuery based application. A single web page
I'm working on a very complex iPad app which may run about 10 separate
I'm working on a project. The makefile is very complex as it includes multiple
I'm currently working in a very complex Perl architecture, and I want to create
I'm working with a very complex Flash project which is part of a full
I'm working on a simulator that models very complex interactions between many objects, and
I'm working on a very complex ASP.NET Web application. The menu is a Treeview
My IDE has been working very well, until today. When I try to compile
I've been working very long on trying to straighten this out, but I just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.