Ruby on rails 具有嵌套资源的声明式授权
我来这里是万不得已的办法,什么都试过了,只是没用。这就来了 这是我的授权码:Ruby on rails 具有嵌套资源的声明式授权,ruby-on-rails,resources,nested,declarative-authorization,Ruby On Rails,Resources,Nested,Declarative Authorization,我来这里是万不得已的办法,什么都试过了,只是没用。这就来了 这是我的授权码: role :department_admin do #Department has many users through designations has_permission_on [:departments], :to => [:manage] do if_attribute :designations => contains {user.designation} end has
role :department_admin do
#Department has many users through designations
has_permission_on [:departments], :to => [:manage] do
if_attribute :designations => contains {user.designation}
end
has_permission_on :users, :to => [:read]
has_permission_on :users, :to => [:create, :update, :destroy] do
if_permitted_to :manage, :department
end
我的部门控制器代码:
filter_resource_access
#and the rest
在用户和控制器中:
filter_resource_access :nested_in => :departments
# and the rest
我试图遵循声明性的github页面上给出的示例应用程序中使用的模式,但徒劳无功
因此,当我尝试创建新用户时,使用此配置
我明白了
任何人都可以帮忙 您能否验证该部门ID是否包含在路线中?是的。不管怎么说,我换成了坎坎舞,它太棒了!
Couldn't find Department without an ID