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| %> <div> <% form_tag :action => :manipulate_based_on_input do %> If you click the button below this person : <% image_tag (peron.photo_url) %> will be tranformed into a<%=h holiday_character %> <%= hidden_field( :holder1, :value => person.id )%> <%= hidden_field( :holder2, :value => holiday_character ) %> <% submit_tag "click here" %> <% end %> </div> <% end %> <% 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?) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you''re using hidden_field as though you are using hidden_field_tag. You need to specify an object for the hidden_field tag or switch over to hidden_field_tag. <%= hidden_field_tag ''test'', ''value'' %> Will give you params[:test] as "value" On Dec 17, 2007 1:23 PM, Tom Norian <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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| %> > <div> > <% form_tag :action => :manipulate_based_on_input do %> > If you click the button below this person : > <% image_tag (peron.photo_url) %> > will be tranformed into a<%=h holiday_character %> > > <%= hidden_field( :holder1, :value => person.id )%> > > <%= hidden_field( :holder2, :value => holiday_character ) %> > <% submit_tag "click here" %> > <% end %> > </div> > <% end %> > <% 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?) > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 17 Dec 2007, at 02:53, Tom Norian wrote:> > 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| %> > <div> > <% form_tag :action => :manipulate_based_on_input do %> > If you click the button below this person : > <% image_tag (peron.photo_url) %> > will be tranformed into a<%=h holiday_character %> > > <%= hidden_field( :holder1, :value => person.id )%> > > <%= hidden_field( :holder2, :value => holiday_character ) %> > <% submit_tag "click here" %> > <% end %> > </div> > <% end %> > <% end %> > > Ok hopefully I didnt make any typos above because it isnt my exact > code > thats on a different machine.That''s really unhelpful. If you are going to post code, post exactly what you are using. Often enough, the devil is in the detail. As it is people have to guess whether what looks like a mistake is a mistake or just a typo.> > > 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"=>""} } >Check the docs for hidden_field_tag (I''m assuming that''s what you actually meant, rather than what you''ve remembered). The second parameter is the value, but you''re passing :value => foo.> 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" .?? >According to your code above, Santa is a class/module. You want to be passing an actual string to hidden field. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, 2007-12-17 at 03:53 +0100, Tom Norian wrote:> 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| %> > <div> > <% form_tag :action => :manipulate_based_on_input do %> > If you click the button below this person : > <% image_tag (peron.photo_url) %> > will be tranformed into a<%=h holiday_character %> > > <%= hidden_field( :holder1, :value => person.id )%> > > <%= hidden_field( :holder2, :value => holiday_character ) %> > <% submit_tag "click here" %> > <% end %> > </div> > <% end %> > <% 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?)---- <%= hidden_field ''holder2'', :value => "Santa" %> <%= hidden_field ''holder1'', :value => person.id %> Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 17 Dec 2007, at 03:05, Frederick Cheung wrote:> > Check the docs for hidden_field_tag (I''m assuming that''s what you > actually meant, rather than what you''ve remembered). The second > parameter is the value, but you''re passing :value => foo. >Meant to add: if you do mean hidden_field, then you need to say hidden_field instance_variable_name, method, :value => ''foo'' Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> you''re using hidden_field as though you are using hidden_field_tag. > > You need to specify an object for the hidden_field tag or switch over to > hidden_field_tag. >Thanks a bunch Ryan, the hidden_field_tag did the trick! Fred, MY home office in the garage got too cold to work in and the machine with rails and the code on it is sitting out of reach of a cable! (I do hear your point about the devil being in your details and I will need to scratch my head about that as I certainly want to do everything I can to be couteous to people so generously helping). It does look like I made an error with my example of the character array ..for it to be a string, not a class/module the array should have been ["Santa", "Elf", "Reindeer"] (with the quotes). I apoligize that my typing stuff in out of my head instead of from something i tested let that through. Thanks for the help on this and the pointers for the clickable divs last night... I''ve almost got yesterday''s question worked out now. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
mcf1986-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-21 10:25 UTC
Re: hidden fields params
You may have fixed this by now, but for anyone else. it''s hidden_field_tag. Matt On Dec 17 2007, 3:05 am, Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> On Mon, 2007-12-17 at 03:53 +0100, Tom Norian wrote: > > 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| %> > > <div> > > <% form_tag :action => :manipulate_based_on_input do %> > > If you click the button below this person : > > <% image_tag (peron.photo_url) %> > > will be tranformed into a<%=h holiday_character %> > > > <%= hidden_field( :holder1, :value => person.id )%> > > > <%= hidden_field( :holder2, :value => holiday_character ) %> > > <% submit_tag "click here" %> > > <% end %> > > </div> > > <% end %> > > <% 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?) > > ---- > <%= hidden_field ''holder2'', :value => "Santa" %> > <%= hidden_field ''holder1'', :value => person.id %> > > Craig--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---