Class: EmailMailer

Inherits:
ActionMailer::Base
  • Object
show all
Includes:
ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper
Defined in:
app/mailers/email_mailer.rb

Instance Method Summary collapse

Instance Method Details

#with_layout(email, subscriber) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/mailers/email_mailer.rb', line 8

def with_layout(email, subscriber)
  @email           = email
  @subscriber      = subscriber
  @email_subject   = @email.render(:subject, @subscriber)
  @text            = @email.render(:body,    @subscriber)
  @base_url        = "http://#{Spree::Config[:site_url]}"
  @link_to_browser = read_email_url(@subscriber.token, @email.token)
  
  unless @email.nil? || @email_subject.empty? || @text.empty?
    mail(:to => @subscriber.email, :from => @email.from, :subject => @email_subject) do |format|
      format.text { render :text   => @text }
      format.html { render :layout => 'email', :text => simple_format(@text) }
    end
  end
end