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

Jeff
Wed, 21 Mar 2007 20:37:31 -0000

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