Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing hash as values in hidden_field_tag

I am trying to pass some filters in my params through a form like so:

hidden_field_tag "filters", params[:filters]

For some reason the params get changed in the next page. For example, if params[:filters] used to be...

"filters"=>{"name_like_any"=>["apple"]} [1]

...it gets changed to...

"filters"=>"{\"name_like_any\"=>[\"apple\"]}" [2]

note the extra quotations and backslashes in [2] when compared to [1].

Any ideas? I'm attempting to use this with searchlogic for some filtering, but I need it to persist when I change change objects in forms. I would prefer not to have to store it in session.

like image 835
funkymunky Avatar asked Mar 24 '10 07:03

funkymunky


1 Answers

My solution was just to re-create each of param with key-value pair:

<% params[:filters].each do |key,value| %>
<%= hidden_field_tag "filters[#{key}]",value %> 
<% end %>
like image 182
okliv Avatar answered Oct 11 '22 21:10

okliv