High Voltage error: undefined method `layout' for HighVoltage::PagesController:Class

516 Views Asked by At

I'm using ruby 2.1.2 and rails 4.1.1.

When I launch my app with 'rails s' I get no error in the terminal but when i enter in a web address for any page of the site, the terminal throws up this error:

undefined method `layout' for HighVoltage::PagesController:Class

Any ideas what i might be doing wrong?

1

There are 1 best solutions below

0
xtian On

This means your ApplicationController isn't inheriting from ActionController::Base (for instance if you are using Rails::API and inheriting from ActionController::API).

If you want to leave the parent class of ApplicationController unchanged, one workaround is to make your own PagesController:

# app/controllers/pages_controller.rb
class PagesController < ActionController::Base
  include HighVoltage::StaticPage
end

# config/routes.rb
get 'pages/home', to: 'pages#show', id: 'home'