Rails is not rendering my application layout

后端 未结 2 1215
终归单人心
终归单人心 2021-02-07 02:45

I just created a new rails app in Rails 3.1.1, and my application layout is not being rendered in the browser. The only thing that is rendered is the code that I put in the view

2条回答
  •  余生分开走
    2021-02-07 02:54

    I just ran into this same problem myself and the problem is just a simple mistake.

    Your controller PublicController is subclassing "ActionController::Base". Controllers other than your ApplicationController need to subclass from ApplicationController in order for their views to be rendered within the application.html.erb layout

    If you change

    PublicController < ActionController::Base
    

    to

    PublicController < ApplicationController
    

    it should work.

提交回复
热议问题