Pat Maddox
2006-Dec-29 16:26 UTC
Remote API passing in parameter named ''action'', routing loses it
I''m working with a remote API that calls a URL in my app, passing in a parameter named action. So the request would look like: http://localhost/my_controller?action=foo Routing correctly interprets the controller action as index. However, it sets params[:action] to index as well. I know that''s how it''s supposed to work...but it means I lose the action parameter passed in. What''s the easiest way to get the action parameter? I can''t change the name, at least on the API end. Pat --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pat Maddox
2006-Dec-29 18:04 UTC
Re: Remote API passing in parameter named ''action'', routing loses it
On 12/29/06, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m working with a remote API that calls a URL in my app, passing in a > parameter named action. So the request would look like: > > http://localhost/my_controller?action=foo > > Routing correctly interprets the controller action as index. However, > it sets params[:action] to index as well. I know that''s how it''s > supposed to work...but it means I lose the action parameter passed in. > What''s the easiest way to get the action parameter? I can''t change > the name, at least on the API end.And actually, it uses POST, so I can''t use URL rewriting. Pat --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jamie Wilson
2006-Dec-30 16:44 UTC
Re: Remote API passing in parameter named ''action'', routing loses it
On 29/12/06, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m working with a remote API that calls a URL in my app, passing in a > parameter named action. So the request would look like: > > http://localhost/my_controller?action=fooI had the same issue. Ended up playing with request.request_uri to extract the value. ...j --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Dan Manges
2006-Dec-31 02:23 UTC
Re: Remote API passing in parameter named ''action'', routing loses it
Pat Maddox wrote:> And actually, it uses POST, so I can''t use URL rewriting.If it is a POST, in your controller: CGIMethods.parse_query_parameters(request.raw_post) That should give you a hash of the post parameters before the routes overwrite action, so you should be able to retrieve action with: CGIMethods.parse_query_parameters(request.raw_post)["action"] Dan Manges --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pat Maddox
2007-Jan-02 18:36 UTC
Re: Remote API passing in parameter named ''action'', routing loses it
On 12/30/06, Dan Manges <daniel.manges-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Pat Maddox wrote: > > And actually, it uses POST, so I can''t use URL rewriting. > > If it is a POST, in your controller: > CGIMethods.parse_query_parameters(request.raw_post) > > That should give you a hash of the post parameters before the routes > overwrite action, so you should be able to retrieve action with: > CGIMethods.parse_query_parameters(request.raw_post)["action"] > > Dan MangesHey Dan, worked great, thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---