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
On Tue, May 19, 2009 at 7:41 AM, Ryan Bigg <radarlistener@gmail.com>
wrote:
>
> 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?
>
> -----
> Ryan Bigg
> Mocra - Premier iPhone and Ruby on Rails Consultants
> w - http://mocra.com
> e - radar@mocra.com
> p - +61 432 937 289 or +61 7 3102 3237
> skype - radarlistener
>
>
>
>
>
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---