ruby on rails - How do I find all the relatives of a node in ancestry? -


i using ancestry gem, , want detected related posts current post.

so post has_ancestry.

in related posts section of view, have this:

<% if @post.has_children? %>     <p>         <ul>     <% @post.children.each |child| %>              <li><%= link_to child.title, post_path(child)%></li>             <% end %>         </ul>     </p> <% else %>     <p>         there no related posts.     </p> <% end %> </div> 

while approach fine, checks 1 use case (i.e. if post has child). want happen though when person clicks through child, on show page should show post related post too.

in effect parent, don't want have if post.has_parents?, if post.has_children?, if post.has_siblings?, etc.

ideally, relatives detected, , if there relatives want loop through them , display them in homogenous way.

how do that?


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -