Sha256: 252324562bd39c414eeaae1335cbeb1971ee9856f9a52ab34d186744f2b0ac8e
Contents?: true
Size: 1.99 KB
Versions: 34
Compression:
Stored size: 1.99 KB
Contents
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: t(".success", model_name: "donation") else flash.now[:error] = t(".failed", model_name: "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: t(".success", model_name: "donation") else flash.now[:error] = t(".failed", model_name: "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
34 entries across 34 versions & 1 rubygems