I created a simple post controller with scaffolding and I want send a mail if someone visiting the index page.
I generated a TestMail class:
class TestMail < ActionMailer::Base
def welcome_email(sent_on)
recipients 'lorem@ipsum.sa'
from "My Awesome Site Notifications <notifications@example.com>"
subject "Welcome to My Awesome Site"
sent_on Time.now
end
end
But if I call this method in Post controller
asd=TestMail.welcome_email(Time.now)
I got NoMethod error:
NoMethodError in PostsController#index
undefined method `welcome_email' for TestMail:Class
What’s wrong?
You’re using the Rails 3 syntax.
With Rails 2.3, you need to use
deliver_orcreate_.