I am getting an error running the following method in an after_save callback
NoMethodError in ApprovalsController#update
Attempt to call private method `create’
def create_next_approval
self.recommendation.create :email => self.next_approver_email #if next_approver_email? && recently_approved?
end
This method is giving me fits in general. I am trying to create a new object after_save using an attribute: next_approver_email.
I also had to comment out the second part of the method because it was returning a no method error: next_approver_email?
I thought I could pass a ? to a method and it would check it?
If your model has been defined as
has_many :recommendationsthen you have to use the plural form of the word eg:As to checking the email – as the commenter mentioned, you can use empty?, or (better yet) present? eg: