How can I create a checkbox that stores a hash, so that when I retrieve the value in params array I get a hash.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
In your controller
@hash = [your hash code]In your view:
<% check_box_tag 'name', @hash %>Use the other view helpers if you want to make it part of a form http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M002256 and http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html
EDIT: Based on the comments below
You’ll need to do things a little differently.
Build your checkbox like this:
<%= check_box :search, "conditions", {:onclick => "refreshResults(this);"}, "#{result.to_s}=#{option.to_s}" %>This will produce checkboxes where
value="city=blah blah", when you process this in rails do:You can then use your search hash to filter.