authenticate_user!对于除单个页面以外的所有页面——如何轻松做到这一点?

authenticate_user! for all but a single page -- how to do that easily?

我想在我的 Rails 应用程序中全部使用 authenticate_user!,但只有一个 "login" 页面。为此,我可以在所有控制器中插入 authenticate_user!。但是将它插入 ApplicationController 和 仅在 "login" 页面或 SessionController 中禁用 "login" 操作。可能吗?

是的,你可以。,

class ApplicationController
  before_filter :authenticate_user!
end

class SessionsController < ApplicationController
  skip_before_filter :authenticate_user!
end

您可以使用 except:.

提及要排除的方法