class ParentRelationshipsController
Public Instance Methods
Source
# File app/controllers/parent_relationships_controller.rb, line 36 def confirm_destroy = render :destroy def destroy @parent_relationship.destroy! redirect_to edit_patient_path(@patient), flash: { success: "Parent relationship removed" } end private def set_patient @patient = policy_scope(Patient).find(params[:patient_id]) end def set_parent_relationship @parent_relationship = authorize @patient .parent_relationships .includes(:parent) .find_by!(parent_id: params[:id]) end def set_parent @parent = @parent_relationship.parent end def parent_relationship_params params.expect( parent_relationship: [ :type, :other_name, { parent_attributes: %i[ id full_name email phone phone_receive_updates contact_method_other_details contact_method_type ] } ] ) end end
Source
# File app/controllers/parent_relationships_controller.rb, line 13 def create authorize @parent_relationship = @patient.parent_relationships.build(parent_relationship_params) if @parent_relationship.save redirect_to edit_patient_path(@patient) else render :new, status: :unprocessable_entity end end
Source
# File app/controllers/parent_relationships_controller.rb, line 38 def destroy @parent_relationship.destroy! redirect_to edit_patient_path(@patient), flash: { success: "Parent relationship removed" } end
Source
# File app/controllers/parent_relationships_controller.rb, line 24 def edit @parent.contact_method_type = "any" if @parent.contact_method_type.nil? end
Source
# File app/controllers/parent_relationships_controller.rb, line 8 def new @parent_relationship = authorize ParentRelationship.new(patient: @patient) @parent_relationship.build_parent end
Source
# File app/controllers/parent_relationships_controller.rb, line 65 def parent_relationship_params params.expect( parent_relationship: [ :type, :other_name, { parent_attributes: %i[ id full_name email phone phone_receive_updates contact_method_other_details contact_method_type ] } ] ) end
Source
# File app/controllers/parent_relationships_controller.rb, line 61 def set_parent @parent = @parent_relationship.parent end
Source
# File app/controllers/parent_relationships_controller.rb, line 53 def set_parent_relationship @parent_relationship = authorize @patient .parent_relationships .includes(:parent) .find_by!(parent_id: params[:id]) end
Source
# File app/controllers/parent_relationships_controller.rb, line 49 def set_patient @patient = policy_scope(Patient).find(params[:patient_id]) end
Source
# File app/controllers/parent_relationships_controller.rb, line 28 def update if @parent_relationship.update(parent_relationship_params) redirect_to edit_patient_path(@patient) else render :edit, status: :unprocessable_content end end