Class: Maily::EmailsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Maily::EmailsController
- Defined in:
- app/controllers/maily/emails_controller.rb
Instance Method Summary collapse
- #attachment ⇒ Object
- #deliver ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #raw ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#attachment ⇒ Object
29 30 31 32 33 |
# File 'app/controllers/maily/emails_controller.rb', line 29 def = @email..find { |elem| elem.filename == params[:attachment] } send_data .body, filename: .filename, type: .content_type end |
#deliver ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/controllers/maily/emails_controller.rb', line 45 def deliver @email.to = params[:to] @email.deliver redirect_to maily_email_path(mailer: params[:mailer], email: params[:email]), notice: "Email sent to <b>#{params[:to]}</b>!" end |
#edit ⇒ Object
35 36 37 |
# File 'app/controllers/maily/emails_controller.rb', line 35 def edit @template = @maily_email.template(params[:part]) end |
#index ⇒ Object
8 9 |
# File 'app/controllers/maily/emails_controller.rb', line 8 def index end |
#raw ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/maily/emails_controller.rb', line 19 def raw content = if @email.parts.present? params[:part] == 'text' ? @email.text_part.body : @email.html_part.body else @email.body end render html: content.raw_source, layout: false end |
#show ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/controllers/maily/emails_controller.rb', line 11 def show valid, = @maily_email.validate_arguments unless valid redirect_to(root_path, alert: ) end end |
#update ⇒ Object
39 40 41 42 43 |
# File 'app/controllers/maily/emails_controller.rb', line 39 def update @maily_email.update_template(params[:body], params[:part]) redirect_to maily_email_path(mailer: params[:mailer], email: params[:email], part: params[:part]), notice: 'Template updated!' end |