Rendering a Collection in a Partial

New to rails and having some trouble rendering a partial. Essentially,
I want the partial to display an index of all the items from another
model. Do I need to add something to the controller to do this?

projects #show.html.erb
<%= render :partial => ‘milestones/list’, :collection=> @milestones
%>

milestones #_list.erb
<% @milestones.each do |milestone| %>

<%=h milestone.name %> <%=h milestone.date_start %> <%=h milestone.date_end %> <%=h milestone.project_id %> <%= link_to 'Show', milestone %> <%= link_to 'Edit', edit_milestone_path(milestone) %> <%= link_to 'Destroy', milestone, :confirm => 'Are you sure?', :method => :delete %> <% end %>

It doesn’t give me an error, but neither does it give me the partial.
If I remove :collection then I get a nil object error.

2009/9/19 Glenn [email protected]:

<% @milestones.each do |milestone| %>
<% end %>

It doesn’t give me an error, but neither does it give me the partial.
If I remove :collection then I get a nil object error.

Have you looked at the html in your browser? View, Page source or
similar. See whether the html is there. It may be that it is not
displaying due to invalid html. I presume that show.html.erb is
generating the table tags?

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs