Page class not recognized

16 views
Skip to first unread message

Dave Lindberg

unread,
Apr 26, 2016, 4:30:59 PM4/26/16
to Refinery CMS
I'm working through my first refinery implementation, and added the following code (from this post) to my view in order to link_to an existing page

13 <div class="right-tile tile"> 
14  <% page = Page.find('Strategy1')%>
15  <%= link_to "Strategy 1", page.url %>
16 </div>

However, the Page class isn't being recognized:

NameError in Refinery::Pages#home
Showing /Users/dlindberg/Ruby/dl-refinery/app/views/refinery/pages/home.html.erb where line #14 raised:

uninitialized constant ActionView::CompiledTemplates::Page

Am I missing a dependency here?

Philip Arndt

unread,
Apr 26, 2016, 5:27:41 PM4/26/16
to refine...@googlegroups.com
Instead of using `Page` you will need to reference its full namespace of `::Refinery::Page`

I've updated the original post to clarify.

Dave Lindberg

unread,
Apr 26, 2016, 7:06:19 PM4/26/16
to Refinery CMS
Making progress, thanks. However, the new issue is how to find an existing page. The page exists at http://localhost:3000/strategy1, here's the error: 

ActiveRecord::RecordNotFound in Refinery::PagesController#home

Couldn't find Refinery::Page with 'id'=test

Extracted source (around line #14):
12
13
14
15
16
17
              
<div class="right-tiles">
<div class="right-tile tile">
<% page = ::Refinery::Page.find("test")%>
<%= link_to "Strategy 1", page.url %>
</div>
...

Philip Arndt

unread,
Apr 26, 2016, 7:07:03 PM4/26/16
to refine...@googlegroups.com
Ahh right, you'll need to use the new API for Friendly ID:

page = ::Refinery::Page.friendly.find("test")

Dave Lindberg

unread,
Apr 26, 2016, 8:43:29 PM4/26/16
to Refinery CMS
Perfect! Thanks again :-)
Reply all
Reply to author
Forward
0 new messages