mirror of
https://github.com/Growstuff/growstuff.git
synced 2025-12-24 01:57:46 -05:00
* Paginate, 100 at a time * Limited i18n * Paginate roles * Pagination * Pagination * i18n and pagination * Paginate alternate names * Silence code climate * Rewrite coverage as a feature * Remove coverage in favour of crops/scientific_name_spec * Add missing admin link * Rewrite coverage as feature * Rewrite coverage --------- Co-authored-by: Brenda Wallace <brenda@wallace.net.nz>
50 lines
969 B
Ruby
50 lines
969 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Admin
|
|
class RolesController < ApplicationController
|
|
before_action :admin!
|
|
load_and_authorize_resource
|
|
respond_to :html
|
|
responders :flash
|
|
|
|
def index
|
|
@roles = Role.all.order(:name).paginate(page: params[:page])
|
|
respond_with @roles
|
|
end
|
|
|
|
def new
|
|
@role = Role.new
|
|
respond_with @role
|
|
end
|
|
|
|
def edit
|
|
respond_with @role
|
|
end
|
|
|
|
def create
|
|
@role = Role.create(role_params)
|
|
respond_with @role, location: admin_roles_path
|
|
end
|
|
|
|
def update
|
|
@role.update(role_params)
|
|
respond_with @role, location: admin_roles_path
|
|
end
|
|
|
|
def destroy
|
|
@role.destroy
|
|
respond_with @role, location: admin_roles_path, notice: "Role was successfully deleted"
|
|
end
|
|
|
|
private
|
|
|
|
def admin!
|
|
authorize! :manage, :all
|
|
end
|
|
|
|
def role_params
|
|
params.require(:role).permit(:description, :name, :members, :slug)
|
|
end
|
|
end
|
|
end
|