Sending mail after_save

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… well, is supposed
to fire it out anyway, but I get an evaluating nil error.

How should I go about this?

Thanks!

Ramon T.

I think you want to look into using an observer.

See: http://api.rubyonrails.org/classes/ActiveRecord/Observer.html