RESTful Rails Naming Conventions with Nested Controllers
Dr. B. | Thursday, May 31, 2007
/site, and the content management tools in a directory
So, how do you get your syntactically-sugar-coated paths when you have a controller in a directory like this:
The map.resources line that worked for me is:
map.resources :users, :controller => 'admin/users', :name_prefix => 'admin_', :path_prefix => '/admin'
Some of the URLs of the resources that are automatically by that line include:
/admin/users: list all users (index action)
/admin/user/1: show one user's details (show action)
/admin/user/new: create a new user (new action)
When you want to use the
*_urlshortcuts for these nested controllers, these work:
Rails is opinionated, but once you figure out how to agree with its opinion of how things should be named, it makes the rest of the development process a lot easier.
Doug Smith, Senior Developer, Barefoot