Hi All I have a HTML-form, that when submitted calles the action called ''abc''. But abc needs to redirect_to a different action, passing to it the ''params'' variable. Any suggestions how to use redirect_to passing it the params variable ? Thnx a lot LuCa -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Luca, Luca Scaljery wrote:> I have a HTML-form, that when submitted calles > the action called ''abc''. But abc needs to redirect_to > a different action, passing to it the ''params'' variable. > > Any suggestions how to use redirect_to passing it > the params variable ?I''m not sure which of 2 problems you''re having, but both have short answers so ... To pass parameters with redirect_to you simply add them. Like ... redirect_to :controller => ''another'', :action => ''def'', :param1 => ''some'', :param2 => ''thing'', :param => ''else'' I''m guessing you''re asking about the fact that parameters only ''live'' for one request-response cycle. redirect_to ends one cycle and starts another so, in the situation you''ve outlined, you''ll need to save them to (a) local variable(s) in the first method, then add them to the redirect_to to receive them in the second. Of course, you could also store them in the session or in the database too. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Bill What happens when you don''t know what varaibles ''params'' contains, so you want to pass all of them with the redirect ? Something like: redirect_to ( :action => ''blabla'', params ) In your example you already know which params to pass on! LuCa -- 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 -~----------~----~----~----~------~----~------~--~---
Luca Scaljery wrote:> Hi Bill > > What happens when you don''t know what varaibles ''params'' contains, so > you want to pass all of them with the redirect ? >How about redirect_to params.join :action => ''new_action'' Stephan> Something like: redirect_to ( :action => ''blabla'', params ) > > In your example you already know which params to pass on! > > LuCa-- 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 -~----------~----~----~----~------~----~------~--~---
I get the feeling we''re almost there :) When I add the params.join I get an error: undefined method `join'' for #<HashWithIndifferentAccess:0xb756b7d8> Any suggestions why ? Thnx LuCa -- 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 -~----------~----~----~----~------~----~------~--~---
Try redirect_to params.merge!(:action => :new_action) RSL On 2/16/07, Luca Scaljery <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I get the feeling we''re almost there :) > > When I add the params.join I get an error: > > undefined method `join'' for #<HashWithIndifferentAccess:0xb756b7d8> > > Any suggestions why ? > > Thnx > LuCa > > -- > 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 -~----------~----~----~----~------~----~------~--~---
this would work, however, there is the problem of nested params, such as what is submitted from a form using form tag helpers where rails handles naming the form fields and thus you could end up with a params hash such as { "user" => { "name" => "bob" } } this would not work as it would end up with a query string like ?user=namebob in the redirect url instead of ?user[name]=bob On 2/16/07, Russell Norris <sconds-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try > > redirect_to params.merge!(:action => :new_action) > > RSL > > > On 2/16/07, Luca Scaljery < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > I get the feeling we''re almost there :) > > > > When I add the params.join I get an error: > > > > undefined method `join'' for > #<HashWithIndifferentAccess:0xb756b7d8> > > > > Any suggestions why ? > > > > Thnx > > LuCa > > > > -- > > 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 -~----------~----~----~----~------~----~------~--~---
Hi Luca, Luca Scaljery wrote:> What happens when you don''t know what > varaibles ''params'' contains, so you want to > pass all of them with the redirect ?I don''t understand this question. The params hash will contain keys for every element in the form you submitted. Some may have an empty string for their value, but they''ll all be there. If you only want to pass along the ones that have values, then you''ll have to examine them before passing them along. BTW... according to Pickaxe, join is not a defined method on a Hash. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thnx, thats the trick. One last thing, using a redirect_to as you suggested, I get an URL that looks like http://blabla.bla/my_controller/new_action?ksdhkv=dgwg&skd........ How can I do a redirect_to which results into the following URL http://blabla.bla/my_controller/new_action Does that not have to do with GET and/or POST ? LuCa Russell Norris wrote:> Try > > redirect_to params.merge!(:action => :new_action) > > RSL-- 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 -~----------~----~----~----~------~----~------~--~---
Yeah. That''s a HTTP method issue there. You might not want to pass wall the params there ''cause it seems to be breaking your routes'' styling. Or just bite the bullet on that ugly URL. I''d opt for the former but that''s me. RSL On 2/16/07, Luca Scaljery <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > thnx, thats the trick. > > One last thing, using a redirect_to as you suggested, I get an URL that > looks like > > http://blabla.bla/my_controller/new_action?ksdhkv=dgwg&skd........ > > How can I do a redirect_to which results into the following URL > > http://blabla.bla/my_controller/new_action > > Does that not have to do with GET and/or POST ? > > LuCa > > Russell Norris wrote: > > Try > > > > redirect_to params.merge!(:action => :new_action) > > > > RSL > > > -- > 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 -~----------~----~----~----~------~----~------~--~---