Routing params helper with :as

Given this in routes.rb (plus more):

map.resources :sites do |site|    map.resources :forums, :as => :boards do |board|      board.resources :topics    end end

And then attempting to go to http://localhost:3000/sites/mocra/boards/1/topics will result in the "1" after "boards" being passed in not as params[:board_id] but as params[:forum_id].

  I think this behaviour is backwards, does anyone agree with this before I go about writing a patch?

I think the current behaviour is correct. It seems to me that :as changes the url and only the url. If it starts to have implications on the controller, that would be very confusing. Say you would use :as to provid l10n names for routes, this is something we do very often. So we have a route like this:

map.resource :potatoes, :as => :potatis

Then in my controller, instead of being able to use the english :potatoe_id, I would have to use the swedish :potatis_id, not good imho.

There’s also a problem with inflection, if the name given to :as is plural (as it probably should be), then the param would have to be pluralized as well (for this to make any kind of sense). Now it gets really icky.

map.resource :forums, :as => :boards

params[:boards_id] # => wtf?

It also makes it harder to reuse the same controller for different routes.

/Jonas