We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
54 lines
1.2 KiB
Ruby
54 lines
1.2 KiB
Ruby
class Admin::ValuatorsController < Admin::BaseController
|
|
load_and_authorize_resource
|
|
|
|
def show
|
|
@valuator = Valuator.find(params[:id])
|
|
end
|
|
|
|
def index
|
|
@valuators = @valuators.page(params[:page])
|
|
end
|
|
|
|
def search
|
|
@users = User.search(params[:name_or_email])
|
|
.includes(:valuator)
|
|
.page(params[:page])
|
|
.for_render
|
|
end
|
|
|
|
def create
|
|
@valuator = Valuator.new(valuator_params)
|
|
@valuator.save!
|
|
|
|
redirect_to admin_valuators_path
|
|
end
|
|
|
|
def edit
|
|
@valuator = Valuator.find(params[:id])
|
|
@valuator_groups = ValuatorGroup.all
|
|
end
|
|
|
|
def update
|
|
@valuator = Valuator.find(params[:id])
|
|
if @valuator.update(valuator_params)
|
|
notice = t("admin.valuators.form.updated")
|
|
redirect_to [:admin, @valuator], notice: notice
|
|
else
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@valuator.destroy!
|
|
redirect_to admin_valuators_path
|
|
end
|
|
|
|
private
|
|
|
|
def valuator_params
|
|
params[:valuator][:description] = nil if params[:valuator][:description].blank?
|
|
params.require(:valuator).permit(:user_id, :description, :valuator_group_id,
|
|
:can_comment, :can_edit_dossier)
|
|
end
|
|
end
|