# How do I add an extra parameter to a REST action?

**URL:** <https://www.ruby-forum.com/t/how-do-i-add-an-extra-parameter-to-a-rest-action/89648>\
**Category:** Rails\
**Created:** [March 21, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/how-do-i-add-an-extra-parameter-to-a-rest-action/89648 "2007-03-21T21:38:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 21, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/how-do-i-add-an-extra-parameter-to-a-rest-action/89648/1 "2007-03-21T21:38:37Z")

</div>

In routes.rb:

map.resources :games

I can do something like this:

games\_path(:sport =\> ‘hockey’)

which results in a path like “/games?sport=hockey”. Awesome.

But elsewhere I have a similar situation where I want to do that to a  
specific game instance:

game\_path(@game, :cancelled =\> ‘true’), :method =\> :put

The idea is that the user clicks a link to cancel the game. I’m using  
the :put method to invoke the update action, but please note that I’m  
not just updating an attribute in the model - it’s telling the  
controller what needs to be done (basically call the @game.cancel  
method, which will run a bunch of business logic).

However, using that syntax doesn’t work:

You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.to\_sym

I could put custom actions on the resource, using :member =\>  
{ :cancelled =\> :put }, but I might end up with ten different actions,  
so this doesn’t seem like the right approach.

Any ideas?

Thanks!  
Jeff

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 21, 2007, 11:39pm UTC](https://www.ruby-forum.com/t/how-do-i-add-an-extra-parameter-to-a-rest-action/89648/2 "2007-03-21T23:39:57Z")

</div>

Hi Jeff,

comments below:

On 21-Mar-07, at 1:37 PM, Jeff wrote:

> But elsewhere I have a similar situation where I want to do that to a  
> specific game instance:
> 
> game\_path(@game, :cancelled =\> ‘true’), :method =\> :put

you can use game\_path(:id =\> @game, :cancelled =\> true) instead.

Alternatively, one of the features of my resource\_fu plugin is being  
able to use that exact syntax. See:

[http://agilewebdevelopment.com/plugins/resource\_fu](http://agilewebdevelopment.com/plugins/resource_fu) for more info.

HTH,  
Trevor

---

<div class="post-metadata">

**Author:** ![jeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@jeff](https://www.ruby-forum.com/u/jeff)\
**Post date:** [March 22, 2007, 3:32pm UTC](https://www.ruby-forum.com/t/how-do-i-add-an-extra-parameter-to-a-rest-action/89648/3 "2007-03-22T15:32:40Z")

</div>

On Mar 21, 4:59 pm, Trevor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> you can use game\_path(:id =\> @game, :cancelled =\> true) instead.
> 
> Alternatively, one of the features of my resource\_fu plugin is being  
> able to use that exact syntax. See:
> 
> [http://agilewebdevelopment.com/plugins/resource\_fu](http://agilewebdevelopment.com/plugins/resource_fu)  
> for more info.
> 
> HTH,  
> Trevor

Thanks, Trevor! That worked great.

Jeff
