Here''s the situation: I need to do a redirect from a controller and I want to pass an object to the redirect but I can''t figure out how to pass it without it being turned into an unreadable string. I''m doing this: 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: "task"=>{"title"=>"fds", "priority"=>"1", "content"=>"d", "user_id"=>"2"} ??? Thanks for your help -- 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 -~----------~----~----~----~------~----~------~--~---
> 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). regards, javier ramirez -- -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
chris young wrote:> Any way I can get it back to looking like the original parameter: > > "task"=>{"title"=>"fds", "priority"=>"1", "content"=>"d", > "user_id"=>"2"}How bout... redirect_to :controller => ''pizza'', task[title] => params[:task][:title], task[priority] => params[:task][:priority], etc, etc no clue if that''ll work, but try it and see. Dave -- 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 -~----------~----~----~----~------~----~------~--~---
On 3/19/07, javier ramirez <jramirez-7iWCczGtl7hBDgjK7y7TUQ@public.gmane.org> wrote:> > > > 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).You could also store it in the session. Isak --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Okay, I''m going to go with passing individual parameters. Man, I wish i hadn''t wasted an hour on this! Thanks Javier and Isak! javier ramirez wrote:>> 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). > > regards, > > javier ramirez > > -- > -------- > Estamos de estreno... si necesitas llevar el control de tus gastos > visita http://www.gastosgem.com !!Es gratis!!-- 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 -~----------~----~----~----~------~----~------~--~---