Class: AlchemyCrm::MailingsMailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/alchemy_crm/mailings_mailer.rb

Instance Method Summary collapse

Instance Method Details

#build(mailing, recipient, options = {}) ⇒ Object

Renders the email sent to the mailing recipient It takes the layout from layouts/alchemy_crm/mailings.erb and renders a html and a text part from it.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/mailers/alchemy_crm/mailings_mailer.rb', line 11

def build(mailing, recipient, options = {})
  @options = options
  ::I18n.locale = @options[:locale]
  @mailing = mailing
  @page = @mailing.page
  @recipient = recipient
  @contact = @recipient.contact || Contact.new_from_recipient(@recipient)

  mail(:to => @recipient.mail_to, :subject => mailing.subject) do |format|
    format.text { render("layouts/alchemy_crm/mailings.text") }
    format.html { render("layouts/alchemy_crm/mailings.html") }
  end
end

#configuration(name) ⇒ Object

Proxy to Alchemy config for view helpers



31
32
33
# File 'app/mailers/alchemy_crm/mailings_mailer.rb', line 31

def configuration(name)
  Alchemy::Config.get(name)
end

#default_url_optionsObject

Setting default url options for rails url_for helpers.



43
44
45
# File 'app/mailers/alchemy_crm/mailings_mailer.rb', line 43

def default_url_options
  {:host => @options[:host], :port => @options[:port]}
end

#logged_in?Boolean

Faking that we are not logged in

Returns:

  • (Boolean)


26
27
28
# File 'app/mailers/alchemy_crm/mailings_mailer.rb', line 26

def logged_in?
  false
end

#sessionObject

Simple session object that contains the language id for view helpers.



36
37
38
39
40
# File 'app/mailers/alchemy_crm/mailings_mailer.rb', line 36

def session
  {
    :language_id => @options[:language_id]
  }
end