why is the "path" field empty on all of my pages?

4 views
Skip to first unread message

lawrenc...@gmail.com

unread,
Apr 9, 2015, 3:50:01 PM4/9/15
to refine...@googlegroups.com
I'm looking in the database for my pages:

select * from refinery_pages \G

I notice that the "path" field is empty on every record. Here is an example: 


*************************** 5. row ***************************
                 id: 6
          parent_id: NULL
               path: NULL
               slug: community
        custom_slug: NULL
       show_in_menu: 1
           link_url: 
         menu_match: NULL
          deletable: 1
              draft: 0
skip_to_first_child: 0
                lft: 13
                rgt: 14
              depth: 0
      view_template: show
    layout_template: NULL
         created_at: 2015-04-04 02:39:56
         updated_at: 2015-04-09 17:36:41


I wanted to build a menu of the pages that are children of other pages. This works if I am on the parent page: 

    current_page_relation = Refinery::Page.friendly.where(slug: params[:path])

If I am on page called Education there in this case the path will be "education" and the slug will be "education" so everything works out great. 

However, if I am on a child page such as "library" then the path is:

education/library

whereas the slug is:

library

I can always split on the "/" but I am curious, is the field "path" suppose to fill in automatically? I'm confused why it doesn't fill in for me. 


Philip Arndt

unread,
Apr 9, 2015, 5:14:12 PM4/9/15
to refine...@googlegroups.com
If you wanted to do this for the current page, you could use something like:

<%= Refinery::Pages::MenuPresenter.new(refinery_menu_pages.select { |p| p.original_id == @page.id && p.original_type == @page.class.name }, self).to_html %>


lawrenc...@gmail.com

unread,
Apr 10, 2015, 1:16:05 PM4/10/15
to refine...@googlegroups.com

Thank you, I am grateful for your answer. I am curious, though, if there is anything I could do to get the "path" field in the database to fill in automatically? It is currently "null" on every record. Seems like ti could be useful to have that in the database, to match against. 
Reply all
Reply to author
Forward
0 new messages