leo
leo

Reputation:

rails layout not showing

I upgraded one of my apps from rails to 2.3.2 from 2.0.2. Start up find. However, once I start running any pages, the page will display but it doesn't seem to render any layout code. None of the standard tag such head, body which are in the layout get render. It seems that somehow layout is turned off. I checked the error log and didn't find any complaint on layout. Has anyone seen this?

Upvotes: 4

Views: 6352

Answers (6)

Johan
Johan

Reputation: 106

It could be that you have overrided initialize() in your controller so that the layout is ignored.

See: will initialize break the layout settings in rails?

Upvotes: 7

aussiegeek
aussiegeek

Reputation: 2950

Is it affecting all controllers?

If not look app/views/.html.erb which is probably very blank

Upvotes: 0

klew
klew

Reputation: 14967

Look if you have file app/views/layouts/application.html.erb - it should be your default layout. I'm not sure but I think Rails in some version changed default layout file name and also, somewhere in the past, changed file extension.

Upvotes: 1

James A. Rosen
James A. Rosen

Reputation: 65232

I believe that somewhere between Rails 2.0 and 2.3 the location of ApplicationController changed from app/controllers/application.rb to app/controllers/application_controller.rb. Is it possible that because of this (or some other reason) your ApplicationController isn't getting loaded properly? If so, and if you defined layout in that class, it might not be picking up the default layout.

Upvotes: 0

bb.
bb.

Reputation: 1400

Have you tried to set the layout explicityly? (For debugging only)

render :layout => "mylayout"

This may help you to find typos. A colleague once had a space after his layout name, "application.html.erb " which we found this way.

Upvotes: 1

awake2night
awake2night

Reputation: 161

It's hard to say for sure based on what you have provided, but a couple things you might check:

  1. Do your layouts have the correct file extensions (.html.erb instead of .rhtml)

  2. Does the layout name match the controller name or if not is the layout name declared inside the controller

  3. I am assuming the layouts are in the correct directory in your application (app/views/layouts)

Best of luck

Upvotes: 0

Related Questions