# Sending mail after\_save

**URL:** <https://www.ruby-forum.com/t/sending-mail-after-save/138980>\
**Category:** Rails\
**Created:** [May 29, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/sending-mail-after-save/138980 "2008-05-29T18:40:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [May 29, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/sending-mail-after-save/138980/1 "2008-05-29T18:40:36Z")

</div>

Hi everyone!

I want to send mail to certain users telling them that a record was  
created, and where they can find it. I tried using after\_create  
:deliver\_notice but the mailer can’t seem to evaluate the created  
object.

For example: People save settings saying “when a new product is added,  
email me”. So, in product.rb, after\_create :deliver\_notice.  
deliver\_notice in mailer.rb fires out the email saying check out the  
new product at [domain.com/products/28-the-new-one](http://domain.com/products/28-the-new-one)… well, is supposed  
to fire it out anyway, but I get an evaluating nil error.

How should I go about this?

## Thanks!

Ramon T.

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [May 29, 2008, 6:46pm UTC](https://www.ruby-forum.com/t/sending-mail-after-save/138980/2 "2008-05-29T18:46:28Z")

</div>

I think you want to look into using an observer.

See: [http://api.rubyonrails.org/classes/ActiveRecord/Observer.html](http://api.rubyonrails.org/classes/ActiveRecord/Observer.html)
