Files
nairobi/app/controllers/admin/valuators_controller.rb
Javi Martín 65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00

51 lines
1.1 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[:search]).includes(:valuator).page(params[:page])
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