Class: Renalware::Messaging::Internal::MessagesController

Inherits:
BaseController show all
Includes:
PresenterHelper, Concerns::Pageable
Defined in:
app/controllers/renalware/messaging/internal/messages_controller.rb

Instance Method Summary collapse

Methods included from PresenterHelper

#present

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/renalware/messaging/internal/messages_controller.rb', line 18

def create
  authorize Message, :create?
  form = MessageForm.new(message_params)

  if form.valid?
    message = SendMessage.call(author: author, patient: patient, form: form)
    flash.now[:notice] = "Message was successfully sent"
    render_create(message)
  else
    render_new(form)
  end
end

#newObject



12
13
14
15
16
# File 'app/controllers/renalware/messaging/internal/messages_controller.rb', line 12

def new
  authorize Message, :new?
  form = MessageFormBuilder.new(patient: patient, params: params).call
  render_new(form)
end