On 4 February 2011 20:30, Paul <[email protected]> wrote: > I've always thought that validating the :parent (and not the foreign > key) is the *more* correct thing to do ... but I don't understand why > Rails does not reset the parent association when the parent_id is > changed as demonstrated here, > > Any thoughts?
yep... don't update foreign ids - update associated objects: > child = Child.find(..) > child.parent = nil one less step ;-) > I've never > been able to get a definite answer on whether one should do, > > validates :parent, :presence => true yep - always validate the object - no sense validating a foreign key field, when the foreign key might not link to a row in the association table. That's my preference anyhoo... -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
