views:

314

answers:

6

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?

A: 

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

Uplate
1. yes2. yes. it match.3. yes
A: 

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.

bb
Yeah, I have tried that and it works. But it you take :layou=> 'mylayout" after render, it won't work
A: 

Could you post your controller, layout, and view files up? Might just take a second eye to spot a bloober :-)

btelles
A: 

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.

James A. Rosen
When I've been gotten by this, the app won't start because application.rb defines ApplicationController instead of Application.
wesgarrison
+1  A: 

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.

klew
yeah. and make sure your file extension is in right order. that was my problem once :) application.erb.html wasn't supported anymore after a certain release of Rails :)
Labuschin
A: 

Is it affecting all controllers?

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

aussiegeek