I have a list of customers that I send emails using an ActionMailer mailer. I am trying to code a link at the bottom of each email so a customer can unsubscribe from a mailing. So far I have an opted_out field in my customers database, I am simply unsure how to properly set up the route and have it update the correct database field. I want to design this so the user can simply click the link and viola, unsubscribed.
in blast_mailer.rb
def mail_blast(customer, blast)
@customer = customer
@blast =blast
#what conditional statement goes here?
mail(:to => @customer.email, :subject => @blast.subject)
@blast.update_attributes(:last_sent => DateTime.now)
end
in mail_blast.html.erb
<div style="font-family:Helvetica; font-size:12pt; font-style:italic; width:500px; height:auto;">
<img src="http://www.ratatouillecatering.com/<%=asset_path("emailheader.png")%>" alt="Menu" />
<br />
<br />
Dear <%= @customer.fname %> <br />
<%= raw(@blast.content) =%> <br />
#what goes here? a link_to what?
<br />
</div>