43

I'm building a website for a rabbit farmer (let's pretend). This man keeps a close eye on his rabbits, and wants them all categorized. So I built him a RabbitCategoriesController, and added this line to my routes.rb

resources :rabbit_categories

The URLs are showing up as rabbit_categories, rabbit_categoriew/new, etc.

What if I want the URLs to look like rabits/categories rabits/categories/new instead? This is not a nested resource, I just want to change the way the URLs look.

Of course, if the resources were called "categories", I could do

namespace :rabbits do
  resources :categories
end

Is there any way I can write that, but tell it to use the RabbitCategoriesController instead of the Rabbits::CategoriesController?

eugen
  • 8,916
  • 11
  • 57
  • 65
declan
  • 5,605
  • 3
  • 39
  • 43

1 Answers1

78

have you tried this, should work

resources :rabbit_categories, :path => "rabbits/categories"

See Rails Routing from Outside In for more details.

rubish
  • 10,887
  • 3
  • 43
  • 57