Hello and thank you in advance. I am fairly new to Ruby and Rails and am working on an app in order to get more familiar. I feel I should be able to solve this problem on my own but have thus far been stymied. Thanks for your help. I used scaffold to generate the basic index/new/show/edit/destroy methods for a given db entries and all works as it should. However, I would like to add a new method -- say "new_special" (for example) -- in the controller. I would expect to do something like: [foo_controller.rb] ... def new_special {some instructions} end ... however, when I browse to this (http://localhost:3000/foo/new_special I see that the engine is trying to invoke the show method and pass it "new_special" as an id. am very confused! I even deleted the ''show'' method but it still calls it! I''ve tried cycling the server and looked everywhere... thanks. Alex -- 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.
This is easy. Say you have a controller users_controller.rb, then in config/routes.rb change: map.resources :users to: map.resources :users, :collection => {:new_special => :get} If you have any other questions, hit me up via twitter (@kconrails) or my blog: http://kconrails.com/contact_me/ Jaime On Jan 16, 9:29 pm, Alex Walters <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello and thank you in advance. > > I am fairly new to Ruby and Rails and am working on an app in order to > get more familiar. I feel I should be able to solve this problem on my > own but have thus far been stymied. Thanks for your help. > > I used scaffold to generate the basic index/new/show/edit/destroy > methods for a given db entries and all works as it should. However, I > would like to add a new method -- say "new_special" (for example) -- in > the controller. > > I would expect to do something like: > > [foo_controller.rb] > ... > def new_special > {some instructions} > end > ... > > however, when I browse to this (http://localhost:3000/foo/new_special > > I see that the engine is trying to invoke the show method and pass it > "new_special" as an id. am very confused! I even deleted the ''show'' > method but it still calls it! > > I''ve tried cycling the server and looked everywhere... thanks. > > Alex > -- > Posted viahttp://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.
Cool. I think I get this (poked a page or two to understand what ":collection" was. I''ll play around. thank you very kindly! Jaime Bellmyer wrote:> This is easy. Say you have a controller users_controller.rb, then in > config/routes.rb change: > > map.resources :users >-- 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.
2010/1/17 Jaime Bellmyer <phoenx64-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> This is easy. Say you have a controller users_controller.rb, then in > config/routes.rb change: > > map.resources :users > > to: > > map.resources :users, :collection => {:new_special => :get}Another alternative which is often appropriate is to use the standard new action but to pass optional additional params in the url to tell it what is ''special''. Colin -- 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.