Search code examples
ruby-on-railslayoutrefinerycms

How do I import refinerycms layouts into a custom controller?


I'm trying to add the refinerycms application layout to a custom controller ie,

layout 'application'

but I get the error

undefined method `browser_title' for nil:NilClass


Extracted source (around line #4):

1: <head>
2:   <meta charset='<%= ::Refinery::Application.config.encoding %>' />
3:   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
4:   <title><%= browser_title(yield(:title)) %></title>
5:   <%= raw "<meta name=\"description\" content=\"#{@meta.meta_description}\" />" if @meta.meta_description.present? -%>
6:   <%= raw "<meta name=\"keywords\" content=\"#{@meta.meta_keywords}\">" if @meta.meta_keywords.present? -%>
7:   <%= csrf_meta_tag if RefinerySetting.find_or_set(:authenticity_token_on_frontend, true)-%>

How do I import the refinery layout into a custom controller?


Solution

  • I ended up doing things the other way around, and overriding the pages controller with my custom controller logic (from this), instead of including the refinery cms layout in my custom controller. This included the right layout, so I didn't get the error anymore.