Files
nairobi/app/controllers/admin/administrators_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

47 lines
1019 B
Ruby

class Admin::AdministratorsController < Admin::BaseController
load_and_authorize_resource
def index
@administrators = @administrators.page(params[:page])
end
def search
@users = User.search(params[:search]).includes(:administrator).page(params[:page])
end
def create
@administrator.user_id = params[:user_id]
@administrator.save!
redirect_to admin_administrators_path
end
def destroy
if current_user.id == @administrator.user_id
flash[:error] = I18n.t("admin.administrators.administrator.restricted_removal")
else
@administrator.destroy
end
redirect_to admin_administrators_path
end
def edit
end
def update
if @administrator.update(update_administrator_params)
notice = t("admin.administrators.form.updated")
redirect_to admin_administrators_path, notice: notice
else
render :edit
end
end
private
def update_administrator_params
params.require(:administrator).permit(:description)
end
end