Noob Question D'Jour

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.


This is easy. Say you have a controller users_controller.rb, then in config/routes.rb change:

map.resources :users


map.resources :users, :collection => {:new_special => :get}

If you have any other questions, hit me up via twitter (@kconrails) or my blog:


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:

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'.