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| %>
<tr>
<td><%=h milestone.name %></td>
<td><%=h milestone.date_start %></td>
<td><%=h milestone.date_end %></td>
<td><%=h milestone.project_id %></td>
<td><%= link_to 'Show', milestone %></td>
<td><%= link_to 'Edit', edit_milestone_path(milestone) %></td>
<td><%= link_to 'Destroy', milestone, :confirm => 'Are you
sure?', :method => :delete %></td>
</tr>
<% 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---