Skip to content

Addresses the fact enums with keyword arguments are deprecated #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/active_admin/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ class Permission < ActiveRecord::Base
self.table_name = :active_admin_permissions
role_based_authorizable

enum state: { cannot: 0, can: 1 }
if Rails::VERSION::STRING >= '7.0.0'
enum :state, { cannot: 0, can: 1 }
else
enum state: { cannot: 0, can: 1 }
end

belongs_to :managed_resource
delegate :class_name, :action, :name, :const, :active?, :for_active_admin_page?, to: :managed_resource
Expand Down
7 changes: 6 additions & 1 deletion lib/active_admin_role/role_based_authorizable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ module RoleBasedAuthorizable
extend ActiveSupport::Concern

included do
enum role: config.roles
if Rails::VERSION::STRING >= '7.0.0'
enum :role, config.roles
else
enum role: config.roles
end

delegate :super_user_roles, :guest_user_roles, to: :class
validates :role, presence: true
end
Expand Down