开发者

Rendering a combo box in a partial

开发者 https://www.devze.com 2023-01-05 09:51 出处:网络
In my project i have this combo box, and it works perfectly: <%= collection_select @project, @project.clients.id, @project.clients, :id, :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 => @projec开发者_JS百科t }%>

and the partial code is:

<%= collection_select :project, clients.id, clients, clients.id, clients.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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消