Sha256: d58ca2089479c17ef8bc0413bf6b73ce480b8ee39e29d9c85201024d36965e6f

Contents?: true

Size: 1.1 KB

Versions: 35

Compression:

Stored size: 1.1 KB

Contents

module Renalware
  module Problems
    class NotesController < BaseController
      before_action :load_patient

      def index
        load_problem
        render_index
      end

      def new
        load_problem
        note = @problem.notes.new
        render_form(note, url: patient_problem_notes_path(patient, @problem))
      end

      def create
        load_problem
        note = @problem.notes.create(notes_params)

        if note.save
          render_index
        else
          render_form(note, url: patient_problem_notes_path(patient, @problem))
        end
      end

      private

      def load_problem
        @problem = patient.problems.find(params[:problem_id])
      end

      def render_index
        render "index", locals: { problem: @problem, notes: notes }
      end

      def render_form(note, url:)
        render "form", locals: { problem: @problem, note: note, url: url }
      end

      def notes_params
        params.require(:problems_note).permit(:description).merge(by: current_user)
      end

      def notes
        @notes ||= @problem.notes.ordered
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.15 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.14 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.13 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.12 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.11 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.9 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.8 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.7 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.5 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.4 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.3 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.2 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.1 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.0 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/problems/notes_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/problems/notes_controller.rb