我的 class Site::BaseController < ApplicationController
中有方法
before_filter :check_layout
def check_layout
if @user.site_theme == 'hometastic'
layout 'hometastic'
else
layout 'agent'
end
end
当我只做
layout 'agent'
它完美地工作
但是当我添加
before_filter
我有 undefined method layout for
rails 3.2.16
有什么建议?
error screen
最佳答案
您可以使用 Rails 在处理请求时用来评估它的符号。 Guides
layout :themed_layout
def themed_layout
if @user.site_theme == 'hometastic'
'hometastic'
else
'agent'
end
end
关于ruby-on-rails - 未定义的方法 `layout',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33276915/