I have the following model with mongoid rails3
class Address
include Mongoid::Document
embedded_in :person, :inverse_of => :address
after_validation :call_after_validation
before_validation :call_before_validation
before_update :call_before_update
after_update :call_after_update
after_create :call_after_create
before_create :call_before_create
field :address1
field :address2
private
def call_after_validation
puts "After validation callback fired."
end
def call_before_validation
puts "Before validation callback fired."
end
def call_before_update
puts "Before update callback fired."
end
def call_after_update
puts "After update callback fired."
end
def call_after_create
puts "After create callback fired."
end
def call_before_create
puts "Before create callback fired."
end
end
class Person
include Mongoid::Document
embeds_one :address
field :name
end
Now I used the nested form to save the face and address immediately.
But all after / before creating / updating the callbacks for the address do not start, except after / before_validation
Any suggestions as to why, after / before creating / updating, callbacks are not triggered for an address when created from a nested form?
thank
Gagan source
share