my tests seem to imply that << forces an insert of the parent and child
records in a has_many relationship when both are newly created objects.
for example,
Controller code:
xy=XY.new
pc=PC.new
xy.addPC(pc)
Model code:
Class XY < ActiveRecord....
def addPC(pc)
self.controls<<pc
end
end
where XY has a "has_many" association with PC and PC has a
"belongs_to"
XY
I note that two INSERTs are performed into the tables behind PC and XY
models as a result of the call to addPC() but I''m not issuing a .save
anywhere in my code.
Is this normal behaviour?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---