Reputation: 1324
I am developing an application that is supposed to have games, when one clicks on the game it will go to game.prestart with instructions and other stuff. There I wrote:
link_to "Play", :controller => "games", :action => "wait"
wait will wait for other players and later redirect to the "play" action
Two questions here:
1.- This is not restful but I dont know how to do it restful, start a game (show?) have 3 phases: prestart, wait and the play itself
2.- That code above will give a "no post action wait" or something like that, if I add :method =>:get I will get a No route matches. I have the method "wait" and the view already created.
Upvotes: 0
Views: 1221
Reputation: 9093
You can add methods in RESTful routing, besides the default ones. Check out section 3.3, Adding more RESTful actions here.
Actually, what you really want is 3.11
Seems like you need additional member routes defined, that way you can generate paths using:
wait_game_path(@game)
To generate the member route, you will need to modify your map.resources :games line in your routes.rb to be something like:
map.resources :games, :member => {:wait => :get}
This will add a new get action of wait for each instance of @game
Upvotes: 2
Reputation: 4436
You can add methods in RESTful routing, besides the default ones. Check out section 3.3, Adding more RESTful actions here.
Upvotes: 0
Reputation: 8305
Here is how you can do that:
I hope that was helpful.
Upvotes: 1