1
0
postdoc/app/controllers/emails_controller.rb

24 lines
530 B
Ruby
Raw Normal View History

2020-12-06 20:49:03 +01:00
class EmailsController < ApplicationController
before_action :set_email, only: [:show, :mark_as_read, :body_preview]
2020-12-11 20:00:57 +01:00
def index
@emails = Email.where(mailbox_id: params[:mailbox_id])
@emails = @emails.search(params[:q]) if params[:q].present?
render(layout: false)
end
2020-12-06 20:49:03 +01:00
def show
@selected = params[:selected]
@email.mark_as_read! unless @email.read?
end
def body_preview
render(layout: false)
end
def set_email
@email = Email.find(params[:id])
@mailbox = @email.mailbox
end
end