Sha256: 0d2e32670db449df84e2b579006b5f0bd22be959336c5a44b1b8c625cb774e84
Contents?: true
Size: 1.13 KB
Versions: 25
Compression:
Stored size: 1.13 KB
Contents
module Renalware module Patients class WorryController < BaseController before_action :load_patient, only: :create # idempotent def create worry = Worry.find_or_create_by!(patient: patient) do |wor| wor.by = user end update_worry_notes_if_supplied(worry) redirect_back(fallback_location: patient_path(patient), notice: t(".success", patient: patient)) end # idempotent def destroy if (worry = patient.worry) authorize worry worry.destroy! else skip_authorization end redirect_back(fallback_location: patient_path(patient), notice: t(".success", patient: patient)) end private def update_worry_notes_if_supplied(worry) if worry_params[:notes].present? worry.update_attributes(worry_params.merge!(by: current_user)) end end def user @user ||= Renalware::Patients.cast_user(current_user) end def worry_params params.require(:patients_worry).permit(:notes) end end end end
Version data entries
25 entries across 25 versions & 1 rubygems