2

我想为我的 Devise 登录页面设置布局,所以我在我的 ApplicationController 中添加了以下内容:

class ApplicationController < ActionController::Base
  protect_from_forgery

  if devise_controller?
    layout "single_column_with_banner"
  end
 end

但是,我收到以下错误: 未定义的方法 `devise_controller?' 对于应用程序控制器:类

我可以看到在 devise.rb 中指定了辅助方法,但我无法从应用程序控制器访问它。我正在使用 Rails 3.2(正在从 2.3 迁移)。我应该在哪里看的任何线索?作为最后的手段,我可​​以覆盖 SessionsController 但我还不想这样做。

4

1 回答 1

1

似乎可以在没有 device_controller 的情况下指定布局?或覆盖 SessionsController。为了指定布局,请将以下内容放在application.rb中:

config.to_prepare do
  Devise::SessionsController.layout "single_column_with_banner"
end
于 2012-02-24T03:08:34.313 回答