Question

My applications currently uses the Ancestry gem to create a navigation tree.

How do I display the name of a page which is the parent of another in the index view?

i.e. currently I do...

<% @pages.each do |page| %>
  <tr>
    <td><%= link_to page.name, edit_page_path(page) %></td>
    <td><%= page.ancestry %></td>
  </tr>
<% end %>

I want the page.ancestry to be the parent's name, not the ID.

Was it helpful?

Solution

<td><%= page.parent.name %></td>

isn't it working?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top