【问题标题】:Haml nesting with rendered partial in Rails在 Rails 中渲染部分的 Haml 嵌套
【发布时间】:2013-05-07 21:38:11
【问题描述】:

考虑这样的 partial.haml:

- haml_tag :body, {:id => @instance_var}

我要做的是在渲染的部分下嵌套haml内容。比如:

= render 'partial_file' do
    %h1 My test
    %p Trying to nest under a partial output.

但这会导致以下视图错误:

'nil' is not an ActiveModel-compatible object that returns a valid partial path.

有没有类似的解决方案可以做到这一点?

【问题讨论】:

    标签: ruby-on-rails nested haml partial-views


    【解决方案1】:

    我根据Rails: How to render repetitive form block? 中的建议通过将渲染指定为:layout 解决了这个问题:

    = render :layout => 'partial_file' do
        %h1 My test
    

    【讨论】:

      猜你喜欢
      • 2014-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 2018-07-13
      • 2011-04-17
      • 2011-05-05
      相关资源
      最近更新 更多