
before :save not called on associations children
Reported by abombss | May 3rd, 2008 @ 03:05 PM
Adding an instance to a one_to_many collection forces a db save but is not calling the before :save method on the associated object. I am using dm edge updated 5/3.
class Account
include DataMapper::Resource
include DataMapper::Timestamp
property :id, Fixnum, :serial => true
property :user_name, String
property :created_at, DateTime
has n, :tweets
before :save, :update_magic_properties
end
class Tweet
include DataMapper::Resource
include DataMapper::Timestamp
property :id, Fixnum, :serial => true
property :content, Text
property :created_at, DateTime
property :account_id, Fixnum, :nullable => false
belongs_to :account
before :save, :update_magic_properties
end
acct = Account.create(:user_name => 'abombss')
acct.tweets << Tweet.new(:content => 'Hello World')
The output from merb isn't showing up in the ticket... after running this :created_at = nil when the call to persist the child is made.
Comments and changes to this ticket
-
Sam Smoot May 8th, 2008 @ 11:58 PM
- Assigned user set to Adam French
We need to ensure we're calling Resource#save everywhere and not Repository#save.
-
Dan Kubb (dkubb) May 9th, 2008 @ 02:12 AM
- State changed from new to resolved
This is now resolved:
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »