How do you call the "before_save" callbacks on an association when saving the parent object? For example:
class Company < ActiveRecord::Base
belongs_to :user
before_save Proc.new { ... } # Not called.
end
class User < ActiveRecord::Base
has_one :company
before_save Proc.new { ... } # Gets called.
end
params = {
:user => {
:name => "Kevin Sylvestre",
:company_attributes => { :city => "Waterloo", :region => "Ontario" }
}
}
@user = User.new(params[:user])
@user.save
Does calls "before_save" on the user, but not on the company. Thanks.