acl9并设计似乎并不配合得很好
-
26-09-2019 - |
题
我有其访问由ACL9控制的用户模型。
在UsersController
:
#ACL9 related stuff
before_filter :load_user, :only => [:show]
access_control do
allow :owner, :of => :user, :to => [:show]
end
def load_user
user = User.find(params[:id])
end
在ApplicationController
:
rescue_from 'Acl9::AccessDenied', :with => :access_denied
def access_denied
authenticate_user! # a method from Devise
end
这是在页http://localhost:3000/users/sign_in
符号在URL输入没有问题,但是当例如我在用户页面键入这是一个问题第一,其中我通过上面的逻辑自动期望被重定向到的登录页
http://localhost:3000/users/1
=>无限重定向地狱。它试图重新定向回users/1
代替再次引导到users/sign_in
的。
没有任何人有意见,什么可能是走错了?
解决方案
我想你不应该在设计用户使用控制器Acl9。由于您未通过身份验证你没有权限,您将无法验证:d。 您可能要禁止用户删除,所以它应该是这样的:
access_control :only => [:destroy] do
allow :admin
end
有关UsersController如果你想离开它是在应用程序控制器,你应该覆盖的ACCESS_CONTROL。
不隶属于 StackOverflow