Currently, this is false: master.slaves.build.master == master This very short patch in AR solves it: http://gist.github.com/60504 The patch also avoids DB calls in: master.slaves.first.master Since it is so simple, what is the reason for not implementing it ? Gaspard PS: Master.has_many :slaves, :class_name => ''Slave'' Slave.belongs_to :master --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Gaspard, That''s a lot simpler than my patch for the same thing, but it doesn''t cover many edge-cases. You can take a look at my patch (and the conversation in the comments) here: http://rails.lighthouseapp.com/projects/8994/tickets/1619 Please join the conversation I''d love to get some more eyeballs and brains thinking about this feature. Regardless of what implementation AR ends up using, I really think it should do *something* like this. Cheers, Murray 2009/2/8 Gaspard Bucher <gaspard@teti.ch>> > Currently, this is false: > > master.slaves.build.master == master > > This very short patch in AR solves it: http://gist.github.com/60504 > > The patch also avoids DB calls in: > > master.slaves.first.master > > Since it is so simple, what is the reason for not implementing it ? > > Gaspard > > > PS: > Master.has_many :slaves, :class_name => ''Slave'' > Slave.belongs_to :master > > > >--~--~---------~--~----~------------~-------~--~----~ 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 8 Feb 2009, at 21:04, Gaspard Bucher wrote:> > Currently, this is false: > > master.slaves.build.master == master > > This very short patch in AR solves it: http://gist.github.com/60504 > > The patch also avoids DB calls in: > > master.slaves.first.master > > Since it is so simple, what is the reason for not implementing it ? > > Gaspard >I seem to recall there was a patch for this, derived from the parental control plugin. While your change handles the simple case I believe it will mess up the more complex cases eg if there are two belongs to the same class you could set the wrong one. I''d also worry that by calling association= you might end up triggering association callbacks and all that jazz (or even updates if partial updates is turned off). Fred> > PS: > Master.has_many :slaves, :class_name => ''Slave'' > Slave.belongs_to :master > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---