anupam
2007-May-03 01:04 UTC
Newbie question: How to get an object in the Controller from a view''s hidden field
Hi, I''m trying to pass an object from the View to the controller as a hidden field. And am confused about a few things. For a hidden field, how do I pass a complete object to the controller? For example, I have an object of type Issue, what should the second argument be in the following: <%= hidden_field("issue", ?, "value" => @issue) %> Is that even possible? Secondly, how would I access this object in the controller? params[:issue][:id] doesn''t work. Someone suggested I should put the object in the session. How do I put and retrieve variables from the session? Any help would be appreciated. Thanks, Anupam. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
MichaelLatta
2007-May-03 01:21 UTC
Re: Newbie question: How to get an object in the Controller from a view''s hidden field
Fields are HTML not Ruby. They only hold text. You can do @issue.id then the controller is going to have to use .to_i to get an integer and Issue.find_by_id to locate the object. Michael On May 2, 6:04 pm, anupam <anupambak...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > I''m trying to pass an object from the View to the controller as a > hidden field. And am confused about a few things. > > For a hidden field, how do I pass a complete object to the > controller? > For example, I have an object of type Issue, what should the second > argument be in the following: > > <%= hidden_field("issue", ?, "value" => @issue) %> > > Is that even possible? > > Secondly, how would I access this object in the controller? > params[:issue][:id] doesn''t work. > > Someone suggested I should put the object in the session. How do I > put and retrieve variables from the session? > > Any help would be appreciated. > > Thanks, > Anupam.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---