In my app i have word model, words_controller and want create new
action for word model.
I create new method 'test' in words_controller, and adds:
resources :words do
member do
put 'test'
end
end
in routes.rb
my rake routes output:
test_word PUT /words/:id/test(.:format) {:action=>"test",
:controller=>"words"}
words GET /words(.:format) {:action=>"index",
:controller=>"words"}
POST /words(.:format) {:action=>"create",
:controller=>"words"}
new_word GET /words/new(.:format) {:action=>"new",
:controller=>"words"}
edit_word GET /words/:id/edit(.:format) {:action=>"edit",
:controller=>"words"}
word GET /words/:id(.:format) {:action=>"show",
:controller=>"words"}
PUT /words/:id(.:format) {:action=>"update",
:controller=>"words"}
DELETE /words/:id(.:format) {:action=>"destroy",
:controller=>"words"}
session POST /session(.:format) {:action=>"create",
:controller=>"sessions"}
new_session GET /session/new(.:format) {:action=>"new",
:controller=>"sessions"}
edit_session GET /session/edit(.:format) {:action=>"edit",
:controller=>"sessions"}
GET /session(.:format) {:action=>"show",
:controller=>"sessions"}
PUT /session(.:format) {:action=>"update",
:controller=>"sessions"}
DELETE /session(.:format) {:action=>"destroy",
:controller=>"sessions"}
login /login(.:format) {:action=>"new",
:controller=>"sessions"}
logout /logout(.:format) {:action=>"destroy",
:controller=>"sessions"}
root /(.:format) {:action=>"index",
:controller=>"words"}
But when i'm going to something like http://localhost:3000/words/22/test
i'm get error
Routing Error
No route matches "/words/22/test"
Why? what am I doing wrong?