Class: Mailbin::MessagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mailbin/messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



36
37
38
39
# File 'app/controllers/mailbin/messages_controller.rb', line 36

def destroy
  Mailbin.destroy(params[:id])
  redirect_to root_path
end

#indexObject



13
14
15
# File 'app/controllers/mailbin/messages_controller.rb', line 13

def index
  @emails = Mailbin.all
end

#showObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/mailbin/messages_controller.rb', line 17

def show
  @email = Mailbin.find(params[:id])
  @attachments = attachments_for(@email).reject { |filename, attachment| attachment.inline? }
  @inline_attachments = attachments_for(@email).select { |filename, attachment| attachment.inline? }

  if params[:part]
    part_type = Mime::Type.lookup(params[:part])

    if part = find_part(part_type)
      response.content_type = part_type
      render plain: part.respond_to?(:decoded) ? part.decoded : part
    else
      raise AbstractController::ActionNotFound, "Email part '#{part_type}' not found in #{@preview.name}##{@email_action}"
    end
  else
    @part = find_preferred_part(request.format, Mime[:html], Mime[:text])
  end
end