# Working with after\_create and Mailer Class

**URL:** <https://www.ruby-forum.com/t/working-with-after-create-and-mailer-class/159109>\
**Category:** Rails\
**Created:** [January 31, 2009, 6:18pm UTC](https://www.ruby-forum.com/t/working-with-after-create-and-mailer-class/159109 "2009-01-31T18:18:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [January 31, 2009, 6:18pm UTC](https://www.ruby-forum.com/t/working-with-after-create-and-mailer-class/159109/1 "2009-01-31T18:18:49Z")

</div>

I am trying to setup sending confirmation emails after creating a new  
instance of Project. In my Project Model, I have an after\_create  
callback that calls the method send\_confirmation. This is working  
fine – the method is called, but I haven’t figured out how to pass  
along the current instance object to the Mailer class I’ve created.

I had assumed that instance variables were accessible from within the  
Project Model, even if created inside of the Project Controller. The  
code below results in error “nil.name undefined”. So how do I get the  
mailer to know of the current instance object in order to send an  
email using its attributes.

Probably doing something stupid. Thanks in advance.

Project Model:

after\_create :send\_confirmation

def send\_confirmation  
Mailer.deliver\_confirm(@project)  
end

Mailer Class:

def confirm(project)  
…  
subject project.name  
…  
end

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [January 31, 2009, 6:39pm UTC](https://www.ruby-forum.com/t/working-with-after-create-and-mailer-class/159109/2 "2009-01-31T18:39:57Z")

</div>

Nevermind, I figured it out. Definitely a “duh” moment. From within  
the class, using self points to the current instance.

Thanks,  
Eric
