Forum: Ruby on Rails Working with after_create and Mailer Class

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eric M. (Guest)
on 2009-01-31 19:18
(Received via mailing list)
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 " 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 Class:

def confirm(project)
Eric M. (Guest)
on 2009-01-31 19:39
(Received via mailing list)
Nevermind, I figured it out.  Definitely a "duh" moment.  From within
the class, using self points to the current instance.

This topic is locked and can not be replied to.