I have a Rails 3.1 app where I just got some weird behavior.
I had two routes declared as follows:
# OLD METHOD
get 'accept_terms', :to => "users_terms#show"
put 'accept_terms', :to => "users_terms#accept'"
Running rake routes included the following:
# accept_terms
# GET /accept_terms(.:format) {:action=>"show", :controller=>"users_terms"}
# PUT /accept_terms(.:format) {:action=>"accept'", :controller=>"users_terms"}
The GET worked fine, but the PUT produced this error:
AbstractController::ActionNotFound (The action 'accept'' could not be found for UsersTermsController):
I confirmed that the action did exist on that controller.
While tinkering around with the problem, I changed the route declarations to:
get 'accept_terms', :controller => 'users_terms', :action => 'show'
put 'accept_terms', :controller => 'users_terms', :action => 'accept'
Running rake routes produced:
# accept_terms
# GET /accept_terms(.:format) {:controller=>"users_terms", :action=>"show"}
# PUT /accept_terms(.:format) {:controller=>"users_terms", :action=>"accept"}
With this, both GET and PUT worked fine.
Is :to => "controller#action not the same as :controller => 'controllerName', :action => 'actionName'?
The only difference I see in the produced routes is the order of :action and :controller…
In the old method you end the
users_terms#acceptwith both a single quote and a double quote.