multiple records using the select_tag
Update: To clear up confusion: by multiple records I mean multiple individuals at once. Each voter would have their own select__tag, this is the reason I want to pass the ID as a hash.
I'm attempting to display multiple records, 开发者_如何学运维with each record displaying its own selection box. I would like to submit this form and pass a hash, having the Add.id function as the key of the hash, and the selection box option pass as the information in the hash. How could I fix my code? is this even possible with the select_tag method?
<%= form_tag yardsign_adds_path, :method => :post do %>
<%= select_tag "support_code[]",
options_for_select([[ "1 - Strong Supporter", add.id ],
[ "2 - Likely Voter" ],
[ "3 - Undecided" ],
[ "4 - Likely Opposed" ],
[ "5 - Strongly Opposed" ]]) %>
<%= submit_tag "Update" %>
<% end %>
Current terminal output:
Started POST "/adds/yardsign" for 127.0.0.1 at 2010-04-17 01:36:03
Processing by AddsController#yardsign as HTML
Parameters: {"commit"=>"Update", "authenticity_token"=>"VQ2jVfzHI7pB+87lQa9NWqvUK3zwJWiJE7CwAnIewiw=", "support_code"=>["1", "3 - Undecided", "3 - Undecided"]}
From the little i get ur question i assuming u want user will able to select more than one option from the select list refer following code (please ignore if you want something else )
<%= select_tag "support_code[]", :multiple=>true
options_for_select([[ "1 - Strong Supporter", add.id ],
[ "2 - Likely Voter" ],
[ "3 - Undecided" ],
[ "4 - Likely Opposed" ],
[ "5 - Strongly Opposed" ]]) %>
精彩评论