Updated

app/controllers/accounts/settings / custom_attributes_definitions_controller.rb

D
51 lines of codes
8 methods
6.9 complexity/method
7 churn
54.91 complexity
54 duplications
class Accounts::Settings::CustomAttributesDefinitionsController < InternalController
  1. Accounts::Settings::CustomAttributesDefinitionsController assumes too much for instance variable '@custom_attribute_definition'
  2. Accounts::Settings::CustomAttributesDefinitionsController has no descriptive comment
before_action :set_custom_attribute_deffinition, only: %i[edit update destroy] def index @custom_attributes_definitions = current_user.account.custom_attributes_definitions end def new @custom_attribute_definition = current_user.account.custom_attributes_definitions.new end def create
  1. Similar code found in 3 nodes Locations: 0 1 2
@custom_attribute_definition = current_user.account.custom_attributes_definitions.new(custom_attribute_definition_params)
  1. Accounts::Settings::CustomAttributesDefinitionsController#create calls 'current_user.account' 2 times Locations: 0 1
if @custom_attribute_definition.save redirect_to account_custom_attributes_definitions_path(current_user.account),
  1. Accounts::Settings::CustomAttributesDefinitionsController#create calls 'current_user.account' 2 times Locations: 0 1
notice: t('flash_messages.created', model: CustomAttributeDefinition.model_name.human) else render :new, status: :unprocessable_entity end end def edit; end def update
  1. Similar code found in 3 nodes Locations: 0 1 2
if @custom_attribute_definition.update(custom_attribute_definition_params) redirect_to edit_account_custom_attributes_definition_path(current_user.account, @custom_attribute_definition), notice: t('flash_messages.updated', model: CustomAttributeDefinition.model_name.human) else render :edit, status: :unprocessable_entity end end def destroy render :index, status: :unprocessable_entity unless @custom_attribute_definition.destroy end private def set_custom_attribute_deffinition @custom_attribute_definition = current_user.account.custom_attribute_definitions.find(params[:id]) end def custom_attribute_definition_params params.require(:custom_attribute_definition).permit( :attribute_model, :attribute_key, :attribute_display_name, :attribute_description ) end end