1

我正在使用 declarative_authorization 并且我在控制器中有以下内容:

filter_access_to :index, :new, :edit, :step, :create, :update, :destroy

有两个动作被遗漏了。:show, :compare. 但是,当我转到其中任何一个操作的 URL 时,它会将我发送到登录屏幕。

为什么是这样 ?

考虑到该控制器上没有其他过滤器(可能从 ApplicationsController 继承的任何内容除外),不应该遗漏的操作允许我在未登录时查看它吗?

4

1 回答 1

3

这不应该与 declarative_authorization ......那是 Devise 的(或任何你的身份验证机制)的域。相反,修改检查用户是否通过身份验证的 before_filter 以包含您想要跳过的操作的异常。

例如。更改before_filter :authenticate_user!before_filter :authenticate_user!, :except=>[:public_action, :other_public_action].

此外,如果你的 before_filter 设置在你的应用程序控制器中,你可以在你想要异常的控制器中覆盖它并在那里制作 mods。

于 2011-03-05T20:30:16.560 回答