Wednesday, 21 August 2013

after_create callback not firing on Model created with nested_attributes_for

after_create callback not firing on Model created with nested_attributes_for

I have two models:
class User
has_many :submissions
accepts_nested_attributes_for :submissions, :allow_destroy => true
end
class Submission
belongs_to :user
after_create :send_confirmation
def send_confirmation
UserMailer.confirm_submission(self)
end
end
In the Controller the Submission model is created by the user model
def create
@user = User.where(:email => user_params[:email]).first_or_create
@user.update_attributes(user_params)
end
The after_create callback is not firing for the Submission model.
How can I get this callback to work?

No comments:

Post a Comment