Sha256: 075951c7d9818ca6f57d5c906113b3f828c8480f85c6811b40e50c7386cc0f93
Contents?: true
Size: 1.66 KB
Versions: 6
Compression:
Stored size: 1.66 KB
Contents
# frozen_string_literal: true module Renalware module Problems class NotesController < BaseController def index render_index end def new note = problem.notes.new authorize(note) render_form( note, url: patient_problem_notes_path(patient, problem) ) end def create note = problem.notes.create(notes_params) authorize(note) if note.save render_index else render_form( note, url: patient_problem_notes_path(patient, problem) ) end end def edit authorize note render_form( note, url: patient_problem_note_path(patient, problem, note) ) end def update authorize note if note.update_by(current_user, notes_params) render_index else render_form( note, url: patient_problem_notes_path(patient, problem) ) end end private def problem @problem ||= patient.problems.find(params[:problem_id]) end def notes @notes ||= problem.notes.includes(:updated_by).ordered end def note notes.find(params[:id]) end def render_index authorize(notes) 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 end end end
Version data entries
6 entries across 6 versions & 1 rubygems