Sha256: e3f4a64b3dbdf8dfa61af9cdb038327afaf55c972d379511263f9b3e033755f4

Contents?: true

Size: 1.16 KB

Versions: 32

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/low_clearance"

module Renalware
  module LowClearance
    class ProfilesController < BaseController
      def edit
        render_edit(find_and_authorize_profile)
      end

      def update
        profile = find_and_authorize_profile
        if profile.update_by(current_user, profile_params)
          redirect_to patient_low_clearance_dashboard_path,
                      notice: t(".success", model_name: "profile")
        else
          flash.now[:error] = failed_msg_for("profile")
          render_edit(profile)
        end
      end

      private

      def find_and_authorize_profile
        (patient.profile || patient.build_profile).tap do |profile|
          authorize profile
        end
      end

      def render_edit(profile)
        render :edit, locals: { patient: patient, profile: profile }
      end

      def profile_params
        params
          .require(:low_clearance_profile)
          .permit(document: [])
          .merge(document: document_attributes)
      end

      def document_attributes
        params.require(:low_clearance_profile)[:document]&.permit!
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
renalware-core-2.0.51 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.50 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.48 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.47 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.46 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.45 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.44 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.43 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.42 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.41 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.40 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.39 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.38 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.37 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.36 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.35 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.34 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.33 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.32 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.31 app/controllers/renalware/low_clearance/profiles_controller.rb