Sha256: 9ca7878690b9641c1e40190c92adde292d19f79e9d160ea77648d23e8cc5beac

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

module Hydra
  module RoleManagement
    module RolesBehavior
      extend ActiveSupport::Concern

      included do
        load_and_authorize_resource 
      end

      def index
      end

      def show
        redirect_to role_management.edit_role_path(@role) if can? :edit, @role
      end

      def new
      end

      def edit
      end

      def create
        @role = Role.new(role_params)
        if @role.save
          redirect_to role_management.edit_role_path(@role), notice: 'Role was successfully created.'
        else
          render action: "new"
        end
      end

      def update
        @role = Role.find(params[:id])
        if @role.update_attributes(role_params)
          redirect_to role_management.edit_role_path(@role), notice: 'Role was successfully updated.'
        else
          render action: "edit"
        end
      end

      def destroy
        if (@role.destroy)
          redirect_to role_management.roles_path, notice: 'Role was successfully deleted.'
        else
          redirect_to role_management.roles_path
        end
      end

      private

      def role_params
        if !ActionController.const_defined? :StrongParameters
          params[:role]
        else
          params.require(:role).permit(:name)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydra-role-management-1.0.0 app/controllers/concerns/hydra/role_management/roles_behavior.rb
hydra-role-management-0.2.2 app/controllers/concerns/hydra/role_management/roles_behavior.rb
hydra-role-management-0.2.1 app/controllers/concerns/hydra/role_management/roles_behavior.rb
hydra-role-management-0.2.0 app/controllers/concerns/hydra/role_management/roles_behavior.rb
hydra-role-management-0.1.0 app/controllers/concerns/hydra/role_management/roles_behavior.rb