Difference in ActionMailer between rails 2 and rails 3

Rails 2


def welcome(user)
    @recipients = “#{user.email}”
    @from = “admin@samplesite.com”
    @subject = “Welcome Mail”
    @body[:user] = user
end

Rails 3


def welcome(user)
    @user = user
    mail(:from=>”admin@samplesite.com”, :to=>”#{user.email}”, :subject=>”Welcome Mail”)
end

We can also set the default value if it is common for all the methods. For ex, consider ‘from’ address is common for all the mail notifications. If so, we can set the default ‘from’ address commonly before the methods, in this case no need to set ‘from’ address in each and every method separately.

default :from => “admin@samplesite.com”

Advertisements

1 thought on “Difference in ActionMailer between rails 2 and rails 3”

  1. An individual usually create the most interesting reports. And also you usually often receive bad/boring stuff and also change these straight into exciting/interesting things. I am the viewer for lifetime!

Comments are closed.