# Remote API passing in parameter named 'action', routing lose

**URL:** <https://www.ruby-forum.com/t/remote-api-passing-in-parameter-named-action-routing-lose/80654>\
**Category:** Rails\
**Created:** [December 29, 2006, 5:28pm UTC](https://www.ruby-forum.com/t/remote-api-passing-in-parameter-named-action-routing-lose/80654 "2006-12-29T17:28:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [December 29, 2006, 5:28pm UTC](https://www.ruby-forum.com/t/remote-api-passing-in-parameter-named-action-routing-lose/80654/1 "2006-12-29T17:28:44Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [December 29, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/remote-api-passing-in-parameter-named-action-routing-lose/80654/2 "2006-12-29T19:07:14Z")

</div>

On 12/29/06, Pat M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](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

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [December 30, 2006, 5:46pm UTC](https://www.ruby-forum.com/t/remote-api-passing-in-parameter-named-action-routing-lose/80654/3 "2006-12-30T17:46:21Z")

</div>

On 29/12/06, Pat M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://localhost/my_controller?action=foo)

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

…j

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [January 2, 2007, 7:41pm UTC](https://www.ruby-forum.com/t/remote-api-passing-in-parameter-named-action-routing-lose/80654/4 "2007-01-02T19:41:28Z")

</div>

On 12/30/06, Dan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Dan M.

Hey Dan, worked great, thanks!

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [December 31, 2006, 3:25am UTC](https://www.ruby-forum.com/t/remote-api-passing-in-parameter-named-action-routing-lose/80654/5 "2006-12-31T03:25:16Z")

</div>

Pat M. 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 M.
