Rails is not rendering my application layout

后端 未结 2 1214
终归单人心
终归单人心 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.

    0 讨论(0)
  • 2021-02-07 03:09

    Ran into the same problem with one final wrinkle: I was overriding initialize in the subclassed controller. Make sure to call 'super' first thing:

    def initialize
        super
        @some_client = SomeClient.new
    end
    
    0 讨论(0)
提交回复
热议问题