Rails 3 渲染:部分

发布于 2024-09-07 15:11:41 字数 507 浏览 0 评论 0原文

我正在将 1.8.7 Rails 应用程序迁移到 Rails 3。但我有一个部分问题: 我有以下部分:

在我的 cms 控制器中:
<代码> @clients = Client.all
组 = render_to_string :layout => '布局/窗口', :partial => '客户/索引'

在我的“clients/index”部分:
<代码> <%= 渲染:部分 => '客户/项目', :collection => @客户%>

这在 Rails 1.7.8 中效果很好,但在 Rails 3 中,仅渲染索引中的部分内容!因此,为了澄清这一点,控制器中的组变量不会从布局中获取 html。 另外奇怪的是,窗口布局是 _window.erb (如果我做 window.html.erb 或只是 window.erb,rails 找不到它,这很奇怪)。

有谁知道这种行为对于 Rails 3 来说是否正常?

谢谢!

I am migrating my 1.8.7 rails app to rails 3. But I have a problem with a partial:
I have the following partial:

in my cms controller :

@clients = Client.all
group = render_to_string :layout => 'layouts/window', :partial => 'clients/index'

in my "clients/index" partial:

<%= render :partial => 'clients/item', :collection => @clients %>

This worked great with rails 1.7.8 but with rails 3 only the partial in the index get's rendered!. So, to clarify this, the group variable in the controller doesn't get the html from the layout.
Also the weird thing is that the window layout is _window.erb (if I do window.html.erb or just window.erb rails can't find it which is strange).

Does anybody know if this behavior is normal for rails 3?

thanxs!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小耗子 2024-09-14 15:11:42

Rails 中的部分字符必须以下划线开头。尝试将“item.html.erb”部分重命名为“_item.html.erb”。

Partials in rails have to start with underscore. Try renaming your "item.html.erb" partial to "_item.html.erb".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文