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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Feb 23, 2011 at 6:09 PM, Aegorov Egorov <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>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 >For Rails 3, replace the above route with *match "/words/:id/test" => "words#test"*> 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? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Feb 23, 2011 at 12:09 PM, Aegorov Egorov <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Phil Crissman wrote in post #983406:> On Wed, Feb 23, 2011 at 12:09 PM, Aegorov Egorov > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> test_word PUT /words/:id/test(.:format) {:action=>"test", >> :controller=>"words"} >> GET /session(.:format) {:action=>"show", >> :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.But when i create link like as <td><%= link_to ''Test'', :controller=>"words", :action=>"test" %> get the same error No route matches {:controller=>"words", :action=>"test"} -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Phil On Wed, Feb 23, 2011 at 2:18 PM, Aegorov Egorov <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Phil Crissman wrote in post #983406: > > On Wed, Feb 23, 2011 at 12:09 PM, Aegorov Egorov > > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > > > >> test_word PUT /words/:id/test(.:format) {:action=>"test", > >> :controller=>"words"} > >> GET /session(.:format) {:action=>"show", > >> :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. > But when i create link like as > <td><%= link_to ''Test'', :controller=>"words", :action=>"test" %> > get the same error > No route matches {:controller=>"words", :action=>"test"} >Because that is still a GET request; you can see this in the logs as well. Also, you never provided a word :id To make it a PUT request, you''d need to do <%=link_to ''test'', test_word_path(@word), :method => :put %> Why do you want it to be a PUT request? If you just want to link to it, 99.99% of the time, it should probably be a GET 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Aegorov Egorov wrote in post #983420:> <td><%= link_to ''Test'', :controller=>"words", :action=>"test" %> > get the same error > No route matches {:controller=>"words", :action=>"test"}1.i''m find the error. i forgot :id => word.id -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.