在部分中渲染组合框
在我的项目中,我有这个组合框,它工作得很好:
<%= 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的部分中尝试此操作:(
当您引用作为局部变量传递到部分的模板实例变量时,请使用变量名称的非符号形式。)
Try this within your partial:
(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.)