Passing a model as a parameter

redirect_to :controller => 'pizza', :task => params[:task]

but it is passing this in the request:

Parameters: {"task"=>"titlesfdspriority1contentsdfuser_id2"}

Any way I can get it back to looking like the original parameter:

well.. for only four parameters maybe you could just pass the four of them directly. If not another common approach is to pass just the id and hit the db again (if you are lucky the last find will be cached, so db will not be even hit).

anyway, for anytime you want to pass something like this you can always serialize. The ruby class for that is Marshal. Not total recall here, but I'd say i saw recently a ticket on the dev site about models not deserializing the relationships properly when using Marshal (just in case).


javier ramirez

You could also store it in the session.