Class: Renalware::Clinics::ClinicVisitsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Renalware::Clinics::ClinicVisitsController
- Defined in:
- app/controllers/renalware/clinics/clinic_visits_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/renalware/clinics/clinic_visits_controller.rb', line 28 def create result = CreateClinicVisit.call(patient, visit_params) visit = result.object.clinic_visit appointment = result.object.appointment_to_build_from if result.success? RememberedClinicVisitPreferences.new(session).persist(visit) notice = success_msg_for("clinic visit") redirect_to patient_clinic_visits_path(patient), notice: notice else flash.now[:error] = failed_msg_for("clinic visit") render :new, locals: { patient: patient, clinic_visit: visit, built_from_appointment: appointment } end end |
#destroy ⇒ Object
57 58 59 60 61 |
# File 'app/controllers/renalware/clinics/clinic_visits_controller.rb', line 57 def destroy @clinic_visit.destroy redirect_to patient_clinic_visits_path(@patient), notice: t(".success", model_name: "clinic visit") end |
#index ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/controllers/renalware/clinics/clinic_visits_controller.rb', line 9 def index visits = patient.clinic_visits.includes([:clinic, :created_by]).ordered render locals: { patient: patient, clinic_visits: CollectionPresenter.new(visits, ClinicVisitPresenter) } end |
#new ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/renalware/clinics/clinic_visits_controller.rb', line 17 def new clinic_visit = build_new_clinic_visit RememberedClinicVisitPreferences.new(session).apply_to(clinic_visit) render :new, locals: { patient: patient, clinic_visit: clinic_visit, built_from_appointment: appointment_to_build_from } end |
#update ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/renalware/clinics/clinic_visits_controller.rb', line 47 def update if @clinic_visit.update(visit_params) redirect_to patient_clinic_visits_path(@patient), notice: t(".success", model_name: "clinic visit") else flash.now[:error] = t(".failed", model_name: "clinic visit") render :edit end end |