Haml嵌套在Rails中渲染部分

时间:2013-05-07 21:38:11

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

考虑像这样的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.

有没有类似的解决方案来实现这个目标?

1 个答案:

答案 0 :(得分:3)

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

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