Skip to content

Commit

Permalink
improve the visibility of the permissions in the admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Mar 13, 2024
1 parent 1397519 commit b0b0752
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ class Permission < ApplicationRecord

validates :target, presence: true
validates :ability, presence: true

def name
"#{target} - #{ability}"
end
end
4 changes: 4 additions & 0 deletions app/models/user_permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ class UserPermission < ApplicationRecord

validates :user, presence: { message: 'must be present' }
validates :permission, presence: { message: 'must be present' }

def name
[user&.email, permission&.name].join(' - ')
end
end
12 changes: 12 additions & 0 deletions config/initializers/rails_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
## To disable Gravatar integration in Navigation Bar set to false
# config.show_gravatar = true

config.model 'Permission' do
object_label_method do
:name
end
end

config.model 'UserPermission' do
object_label_method do
:name
end
end

config.actions do
dashboard # mandatory
index # mandatory
Expand Down

0 comments on commit b0b0752

Please sign in to comment.