You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
`class Admin::BaseController < ApplicationController
include Admin::InheritAction
before_action :authenticate_user!
def current_ability
@current_ability ||= AdminAbility.new(current_user)
end
end`
in admin_ability.rb
`
class AdminAbility
include CanCan::Ability
def initialize(user)
user.roles.each do |role|
role.permissions.each do |permission|
if permission.subject_class == "all"
can permission.action.to_sym, permission.subject_class.to_sym
else
can permission.action.to_sym, permission.subject_class.constantize
end
end
end
end
end
`
User has many roles and role has many permissions. I created a namespace for admin's controllers, like admin/users_controller , i also have another users controller . The admin will manage permissions from the admin/permissions_controller in which admin can assign permissions to any role.
For admin controllers, I checked this Admin Namespace from wiki and applied in my application.
But the problem is that this only manage permissions for admin name space controller and i want to manage permissions of both admin/users_controller and users_controller from admin/permissions page.
What will be the subject_class for User::registrations_controller ? How can i manage the same controller name from admin side ?
I am stuck in problem since last 2 days. can't figure out what should i do ?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
#I applied dynamic role and permissions in my application. For that, i used Abilities-in-Database and dynamic-roles-and-permissions-using-cancan
in base_controller.rb
in admin_ability.rb
`
class AdminAbility
include CanCan::Ability
def initialize(user)
user.roles.each do |role|
role.permissions.each do |permission|
if permission.subject_class == "all"
can permission.action.to_sym, permission.subject_class.to_sym
else
can permission.action.to_sym, permission.subject_class.constantize
end
end
end
`
User has many roles and role has many permissions. I created a namespace for admin's controllers, like admin/users_controller , i also have another users controller . The admin will manage permissions from the admin/permissions_controller in which admin can assign permissions to any role.
For admin controllers, I checked this Admin Namespace
from wiki and applied in my application.
But the problem is that this only manage permissions for admin name space controller and i want to manage permissions of both admin/users_controller and users_controller from admin/permissions page.
What will be the subject_class for User::registrations_controller ? How can i manage the same controller name from admin side ?
I am stuck in problem since last 2 days. can't figure out what should i do ?
The text was updated successfully, but these errors were encountered: