Forum: Ruby on Rails Remote API passing in parameter named 'action', routing lose

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.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-12-29 17:28
(Received via mailing list)
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
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-12-29 19:07
(Received via mailing list)
On 12/29/06, Pat Maddox <pergesu@gmail.com> 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
Ea53b1841bf3c1408fe6fc02561dfcc1?d=identicon&s=25 Jamie Wilson (Guest)
on 2006-12-30 17:46
(Received via mailing list)
On 29/12/06, Pat Maddox <pergesu@gmail.com> 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

I had the same issue. Ended up playing with request.request_uri to
extract the value.

...j
B0f09f622c913a13b9bfd332fca56563?d=identicon&s=25 Dan Manges (Guest)
on 2006-12-31 03:25
(Received via mailing list)
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
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2007-01-02 19:41
(Received via mailing list)
On 12/30/06, Dan Manges <daniel.manges@gmail.com> wrote:
>
> Dan Manges

Hey Dan, worked great, thanks!
This topic is locked and can not be replied to.