Rendering a combo box in a partial
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.)
精彩评论