Ok, I’m working dilegently on my question from yesterday and I will post
the answer once I get one working… but I’m having problems on an
interim stage.
Hidden field basics…I really wrestle getting things in and out of
parameters from view to controller so I’m trying this simple approach.
<% for person in @people %>
<% [Santa, Elf, Reindeer].each do |holiday_character| %>
<%= hidden_field( :holder1, :value => person.id )%>
<%= hidden_field( :holder2, :value => holiday_character ) %>
<% submit_tag "click here" %>
<% end %>
Ok hopefully I didnt make any typos above because it isnt my exact code
thats on a different machine.
MY problem is that the params from the hidden fields look strange.
If I force an error to look at my params I get something like:
{ “commit”=>“click here”, “holder1” =>{“value166”=>""}, “holder1”
=>{“valueSanta”=>""} }
what I want (I think) is more like {. … , “holder1” => “166”, “holder2”
=> “Santa” }
If I instead use a hidden_ield like:
<%= hidden_field( :holder2, holiday_character ) %>
my params look more like {… , “holder2”=>{“Santa”=>""}, …}
Can I get a simple params like “holder2”=>“Santa” .??
If not which of the two alternatives should I use and how do I access
the info in the params?
?? params[:holder2][value] ?? (will it work even with the “value166”=""
subhash?)