Class: Renalware::Messaging::Internal::MessagesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Renalware::Messaging::Internal::MessagesController
- Includes:
- Pagy::Backend, PresenterHelper, Concerns::Pageable
- Defined in:
- app/controllers/renalware/messaging/internal/messages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#index ⇒ Object
Display all public message for a patient.
- #new ⇒ Object
Methods included from PresenterHelper
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/renalware/messaging/internal/messages_controller.rb', line 19 def create Message, :create? form = MessageForm.new() if form.valid? = SendMessage.call(author: , patient: patient, form: form) flash.now[:notice] = "Message was successfully sent" render_create() else render_new(form) end end |
#index ⇒ Object
Display all public message for a patient
33 34 35 36 37 38 |
# File 'app/controllers/renalware/messaging/internal/messages_controller.rb', line 33 def index Message, :index? scope = patient..where(public: true).order(created_at: :desc) pagination, = pagy(scope, items: 20) render locals: { patient: patient, messages: , pagination: pagination } end |
#new ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/renalware/messaging/internal/messages_controller.rb', line 13 def new Message, :new? form = MessageFormBuilder.new(patient: patient, params: params).call render_new(form) end |