Class: EasyMailPreview::EmailsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/easy_mail_preview/emails_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
# File 'app/controllers/easy_mail_preview/emails_controller.rb', line 3

def index
  @mailers = EasyMailPreview.config.mailers.map { |action_mailer|
    EasyMailPreview::Mailer.new(action_mailer)
  }
end

#showObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/easy_mail_preview/emails_controller.rb', line 9

def show
  params[:id] =~ /(.*?)_(.*)/
  mailer = Module.const_get($1)
  method_name = $2
  args = []
  i = 0
  until params["arg_" + i.to_s].blank?
    eval_str = params["arg_" + i.to_s]
    args << eval(eval_str)
    i += 1
  end
  mail = mailer.send(method_name, *args)
  render text: mail.body.to_s, layout: false
end