Rails 2.3.8 mail NoMethod error
class TestMail < ActionMailer::Base
def welcome_email(sent_on)
recipients 'lo开发者_运维百科rem@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_
or create_
.
# creates and delivers the email
TestMail.deliver_welcome_email(Time.now)
# creates the email
email = TestMail.create_welcome_email(Time.now)
精彩评论