I was working on a resources-related patch recently and came across an implementation question... When mapping resources with has_one associations, the has_one association is modeled by the map_associations method as a singleton resource. I thought that a singleton resource was supposed to be global to the application''s current user. has_one''s are not global to the user, they''re global to the resource they belong to. This also has the (I think) unintended effect of looking for a single named controller. For instance: map.resources :products, :has_one => :manufacturer will look for a ManufacturerController not a ManufacturersController. If I wish to access the manufacturers resource outside of the context of this association, I''ll need to add a ManufacturersController as well. Shouldn''t has_one associations be mapped the same way has_many associations are? or am I just not understanding the implementation chosen? Thanks, Marc --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Shouldn''t has_one associations be mapped the same way has_many > associations are? or am I just not understanding the implementation > chosen?I''ve come to the realization that all controllers should always be plural. Whether it''s with map.resource/s, has_many, or has_one. We''ll be changing this shortly. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 5/14/07, DHH <david.heinemeier@gmail.com> wrote:> I''ve come to the realization that all controllers should always be > plural. Whether it''s with map.resource/s, has_many, or has_one. We''ll > be changing this shortly.Are you saying that if I have a map.resource :session that this should map to a plural SessionsController, as opposed to SessionController? -- Josh Knowles joshknowles@gmail.com http://joshknowles.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Are you saying that if I have a map.resource :session that this should map > to a plural SessionsController, as opposed to SessionController?The rationale for this is consistency. Here''s a case where you would want it to be plural: # /avatars, AvatarsController map.resources :avatars # /users/1/avatar, AvatarsController map.resources :users do |user| user.resource :avatar end -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Are you saying that if I have a map.resource :session that this should map > to a plural SessionsController, as opposed to SessionController?Right. As Rick explains, this completely removes the confusion on how controllers should be named. They''re just always plural regardless of whether they''re being exposed through singular or plural resources (or both). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Excellent. Thanks for the explanation. On May 14, 3:00 pm, DHH <david.heineme...@gmail.com> wrote:> > Are you saying that if I have a map.resource :session that this should map > > to a plural SessionsController, as opposed to SessionController? > > Right. As Rick explains, this completely removes the confusion on how > controllers should be named. They''re just always plural regardless of > whether they''re being exposed through singular or plural resources (or > both).--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---