Sha256: 64fa4067510f7259db8b4288423dbe9c0664f183f9cc0ff5727059fdab8e4a2a
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
# frozen_string_literal: true require_dependency "renalware/transplants/base_controller" module Renalware module Transplants class DonationsController < BaseController before_action :load_patient def show donation = Donation.for_patient(patient).find(params[:id]) render locals: { patient: patient, donation: donation } end def new render locals: { patient: patient, donation: Donation.new } end def create donation = Donation.new(patient: patient) donation.attributes = donation_params if donation.save redirect_to patient_transplants_donor_dashboard_path(patient), notice: success_msg_for("donation") else flash.now[:error] = failed_msg_for("donation") render :new, locals: { patient: patient, donation: donation } end end def edit donation = Donation.for_patient(patient).find(params[:id]) render locals: { patient: patient, donation: donation } end def update donation = Donation.for_patient(patient).find(params[:id]) donation.attributes = donation_params if donation.save redirect_to patient_transplants_donor_dashboard_path(patient), notice: success_msg_for("donation") else flash.now[:error] = failed_msg_for("donation") render :edit, locals: { patient: patient, donation: donation } end end private def donation_params params.require(:transplants_donation).permit(attributes) end def attributes [ :state, :recipient_id, :relationship_with_recipient, :relationship_with_recipient_other, :blood_group_compatibility, :mismatch_grade, :paired_pooled_donation, :volunteered_on, :first_seen_on, :workup_completed_on, :donated_on, :notes ] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
renalware-core-2.1.1 | app/controllers/renalware/transplants/donations_controller.rb |
renalware-core-2.1.0 | app/controllers/renalware/transplants/donations_controller.rb |