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
32 33 34 35 36 |
# File 'app/controllers/maily/emails_controller.rb', line 32 def = @email..find { |elem| elem.filename == params[:attachment] } send_data .body, filename: .filename, type: .content_type end |
#deliver ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/maily/emails_controller.rb', line 48 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
38 39 40 |
# File 'app/controllers/maily/emails_controller.rb', line 38 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 28 29 30 |
# File 'app/controllers/maily/emails_controller.rb', line 19 def raw content = if @email.multipart? params[:part] == 'text' ? @email.text_part.body : @email.html_part.body else @email.body end content = content.raw_source content = view_context.simple_format(content) if @email.sub_type == 'plain' || params[:part] == 'text' render html: content.html_safe, 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
42 43 44 45 46 |
# File 'app/controllers/maily/emails_controller.rb', line 42 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 |