在部分中渲染组合框

发布于 2024-09-07 18:02:08 字数 469 浏览 1 评论 0原文

在我的项目中,我有这个组合框,它工作得很好:

<%= collection_select @project, @project.clients.id, @project.clients, :id, :name %>

我简单而快速的问题是,我如何以部分方式呈现它,我正在使用它,但它不起作用......

<%= render :partial => "clients", :collection => @project.clients, :locals => {:project => @project }%>

部分代码是:

<%= collection_select :project, clients.id, clients, clients.id, clients.name %

In my project i have this combo box, and it works perfectly:

<%= collection_select @project, @project.clients.id, @project.clients, :id, :name %>

My simple and quick question is, how can i render this in a partial, I'm using this and it's not working...

<%= render :partial => "clients", :collection => @project.clients, :locals => {:project => @project }%>

and the partial code is:

<%= collection_select :project, clients.id, clients, clients.id, clients.name %

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

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

发布评论

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

评论(1

梦醒灬来后我 2024-09-14 18:02:08

在您的部分中尝试此操作:(

<%= collection_selection project, project.clients.id, project.clients, :id, :name %>

当您引用作为局部变量传递到部分的模板实例变量时,请使用变量名称的非符号形式。)

Try this within your partial:

<%= collection_selection project, project.clients.id, project.clients, :id, :name %>

(When you refer to template instance variables that are passed in to the partial as locals, use the non-symbol form of the variable name.)

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