I’ve noticed that nested resources are also available via the default
route:
In my application I have many gamers and want to give them a singleton
profile resource (example.com/gamers/3/profile). So my config.routes
includes:
map.resources :gamers, :has_one => [:profile]
Even though it’s a singleton, my controller has be pluralized: called
ProfilesController and live at app/controllers/profiles_controller.rb
with views in app/views/profiles.
The problem I see is that the default route also means that the
profiles controller can be accessed at example.com/profiles. Should I
write a before_filter to raise 404 if it can’t find params[:gamer_id]?
It seems the natural place to do this would be config/routes, but the
only way to do that would be to remove the default route and
explicitly list all of my other controllers. Is there a nicer way to
do this that I’m missing?