I have Recommendations has_many Approvals.
When one approval is made, the user provides an email address for the next user who needs to approve.
In my Approval Model
after_save :create_next_approval, :approval_notification
attr_accessor :next_approver_email
def recently_approved?
self.approved_changed? && self.approved?
end
def create_next_approval
#self.recommendations.create :email => self.next_approver_email if next_approver_email.present? && recently_approved?
next_approval = self.recommendation.approvals.build(:email => self.next_approver_email)
next_approval.save if next_approver_email.present? && recently_approved?
end
private
def approval_notification
ApprovalMailer.needs_approval(self).deliver
end
In the create_next_approval method, I am saving the next_approval. I am then sending an email to the next_approver_email address asking them to come approve the recommendation.
I am saving this approval here and I need to link to it in the email being sent out... any ideas?