Sha256: 77d15975985569b8c60e55992fceb090451df80cea76e21679dfba86f4fe0d2b

Contents?: true

Size: 963 Bytes

Versions: 8

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true
require_dependency 'c/admin_controller'

module C
  class Admin::RolesController < AdminController
    load_and_authorize_resource class: C::Role

    def index; end

    def new; end

    def create
      if @role.save
        flash[:success] = 'Role saved.'
        redirect_to roles_path
      else
        render :new
      end
    end

    def edit; end

    def update
      if @role.update(role_params)
        flash[:success] = 'Role updated.'
        redirect_to roles_path
      else
        render :edit
      end
    end

    def destroy
      if @role.destroy
        flash[:success] = 'Role deleted.'
      else
        flash[:error] = 'An error occurred.'
      end
      redirect_to roles_path
    end

    def confirm_destroy; end

    private

    def role_params
      params.require(:role).permit(:name, :body, permissions_attributes: [:id, :permission_subject_id, :read, :new, :edit, :remove])
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cd2_catton_cms-1.1.35 app/controllers/c/admin/roles_controller.rb
cd2_catton_cms-1.1.34 app/controllers/c/admin/roles_controller.rb
cd2_catton_cms-1.1.33 app/controllers/c/admin/roles_controller.rb
cd2_catton_cms-1.1.32 app/controllers/c/admin/roles_controller.rb
cd2_catton_cms-1.1.31 app/controllers/c/admin/roles_controller.rb
cd2_catton_cms-1.1.30 app/controllers/c/admin/roles_controller.rb
cd2_catton_cms-1.1.20 app/controllers/c/admin/roles_controller.rb
cd2_catton_cms-1.1.10 app/controllers/c/admin/roles_controller.rb