Reputation: 4483
I am new to action mailer. I have built an webpage in HAML which contains two tables. I want to embed them in my email body. So I have written the following code:
class AlertsMailer < ActionMailer::Base
default from: '[email protected]'
def mail_alert
email_addresses = ['[email protected]', '[email protected]']
subject = "xyz"
body = <Here I don't know what to write>
logger.warn mail(:to => email_addresses, :subject => subject, :body =>body).deliver!
end
end
So here how do I render the webpage in my mail or do I have to hardcode the table with its data in mail. But value embedded in the tables is supposed to change daily. So how do I implement it?
Upvotes: 0
Views: 145
Reputation: 450
Have a read of this http://guides.rubyonrails.org/action_mailer_basics.html
You need to create a view for the mailer, this is where your content goes, this is all in section 2.1.3.
It also shows you how to create mailers in a slightly different (read better) fashion than your currently using.
Upvotes: 1