content_for
Rails のソースを見てフラッシュできることがわかりました。https://github.com/rails/rails/blob/master/actionpack/lib/action_view/helpers/capture_helper.rb
レールソース:
def content_for(name, content = nil, options = {}, &block)
if content || block_given?
if block_given?
options = content if content
content = capture(&block)
end
if content
options[:flush] ? @view_flow.set(name, content) : @view_flow.append(name, content)
end
nil
else
@view_flow.get(name)
end
end
を設定しようとしてoptions[:flush] = true
いますが、問題が発生しています。以下のoptions[:flush]
私のコードでは true と評価されていません。
私のコード:
content_for(affiliate_link_pos.to_sym, {:flush=>true}) do
render page
end
編集:3番目のパラメータ(コンテンツ)も渡そうとしましたが、wrong number of argument error (3 for 2)
.
content_for(affiliate_link_pos.to_sym, "true", {:flush=>true}) do