我有两个应用程序布局版本,它们只在几行代码上有所不同。请看下面的例子:
!!!
%html
%head
# a lot of code here
%body
# some more code here
- if defined? flag and flag == true
# variant 1
- else
# variant 2
问题是,我如何将此标记传递给布局?
class ApplicationController < ActionController::Base
layout 'layout', :locals => {:flag => true} #won't work :(
# ...
end
params[:action] != 'index'
。 - DanneManneaction_name
的可用 helper。因此,action_name != 'index'
也可以起作用。(这个 helper 和controller_name
都是 Rails 提供的)。 - Gal