In a belongs_to association, is there a way to tell if the associated
object
was newly created?
Hopefully this will explain my question:
A Firm class declares
has_manyhttp://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M000530:clients
and a
client class declares
belongs_tohttp://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M000532:firm.
Now you do the following:
Create a new firm and add clients using firm.clients.create methods.
Note
both firm and clients are unsaved at this point.
Then you save the firm. It appears the sequence of events is
- save the firm
- save the clients
Is it possible for the clients to know if the firm was newly saved? By
the
time the client is being saved firm.new_record? is false.
Any suggestions?
Thanks,
-Kelly