ben
ben

Reputation: 29777

RoR - The views in one of my controllers are not displaying the application layout for no apparent reason

For one of my controllers, all of the views are displaying without the application layout. The application layout works fine for every other controller & view in the application.

Here is a controller whose views display the application template (note: I've made all of the views empty to simplify matters)

class PagesController < ApplicationController  
  def home
    @title = "Home"
  end  
end

And here is the controller whose views won't display the application layout (again, the view itself it empty)

class PersonalentriesController < ApplicationController
  def index
    @personalentries = current_user.personalentries.all
  end
end

What could be causing this? Thanks for reading

Upvotes: 0

Views: 78

Answers (3)

PanosJee
PanosJee

Reputation: 3866

The best thing you can do is to create an applciation.html.erb in your layouts folder This layout will applied to all html views except if you specify else (not to render it or render another one)

Upvotes: 0

Suman Mukherjee
Suman Mukherjee

Reputation: 205

yeah, i guess @buru is right. You must have scaffolded and it generated a layout for that particular controller.

Upvotes: 1

buru
buru

Reputation: 3210

Take a look at your app/views/layouts/ folder. You probably have pages.html.erb there, but not personalentries.html.erb Create personalentries.html.erb in that folder (copypaste from pages.html.erb and modify accordingly). It will work :)

Upvotes: 1

Related Questions