gpt4 book ai didi

ruby-on-rails - 在 Rails 中渲染部分的 Haml 嵌套

转载 作者:行者123 更新时间:2023-12-04 04:58:40 24 4
gpt4 key购买 nike

考虑一个像这样的 partial.haml:

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

我想做的是 在渲染的部分下嵌套 haml 内容 .类似的东西:
= render 'partial_file' do
%h1 My test
%p Trying to nest under a partial output.

但这会导致 View 错误,例如:
'nil' is not an ActiveModel-compatible object that returns a valid partial path.

有没有类似的解决方案来实现这一点?

最佳答案

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

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

关于ruby-on-rails - 在 Rails 中渲染部分的 Haml 嵌套,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16428982/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com