Forum: Ruby on Rails Newbie question: How to get an object in the Controller from

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
37c8f9e9c2318294bf934bd98568580e?d=identicon&s=25 anupam (Guest)
on 2007-05-03 03:04
(Received via mailing list)
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.
588ab1c0a5610a7e160a3b101abb91e6?d=identicon&s=25 MichaelLatta (Guest)
on 2007-05-03 03:22
(Received via mailing list)
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
This topic is locked and can not be replied to.