On Wed, Feb 23, 2011 at 12:09 PM, Aegorov Egorov <li...@ruby-forum.com>wrote:

> 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?
>
>
Your route specifies PUT... but when you go to "/words/22/test" in the
browser, that's a GET request. So no, it's not going to match. You could
either change the route to respond to a GET request, or add a button or link
that visits it via a PUT request.



> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to