Display Ancestry name instead of id

114 Views Asked by At

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.

1

There are 1 best solutions below

4
On BEST ANSWER
<td><%= page.parent.name %></td>

isn't it working?