Sha256: 71fc343e8a528f7b49c67765c44f1335c57290d957699ac81356da993649a689

Contents?: true

Size: 1 KB

Versions: 37

Compression:

Stored size: 1 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(:referrer_id, document: {})
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
renalware-core-2.0.167 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.166 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.165 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.164 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.163 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.162 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.161 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.160 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.159 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.158 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.157 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.156 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.155 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.153 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.152 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.151 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.149 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.148 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.147 app/controllers/renalware/low_clearance/profiles_controller.rb
renalware-core-2.0.146 app/controllers/renalware/low_clearance/profiles_controller.rb