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 lay开发者_如何学编程out. 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
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 :)
yeah, i guess @buru is right. You must have scaffolded and it generated a layout for that particular controller.
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)
精彩评论