views:

598

answers:

1

My application.html.erb is a classic file with the <%= yield %> statement. The expected would be if I went to domain.com/controller/action that it yields to the view in the appropriate directory. Instead, it's pulling up just the view (the correct view, but without the application wrapper). (There's no other layouts other than application)

This is my second rails application. The other one went smoothly, but this one is giving me one problem after another. I rtfm'd and googled and came up with nothing. I even rebooted webrick, though I didn't restart apache (proxypass to webrick), as I thought that overkill. Not to mention we host some low-volume websites.

The strangest thing is, when I call the root ie: domain.com it calls application.html.erb and yields to the home view.

I did use scaffolding, but it was my understanding that calling script/generate scaffold simply builds files and doesn't configure anything except routes. Which I already fixed.

Thanks in advanced for your help!

Things I thought might help answer question. Let me know if you need more.

Devel logs where it's obvious that layouts application isn't loading:

domain.com

Processing HomeController#index (for 24.20.194.187 at 2009-09-03 15:24:15) [GET]
  Parameters: {"action"=>"index", "controller"=>"home"}
  ESC[4;35;1mCompany Columns (2.6ms)ESC[0m   ESC[0mSHOW FIELDS FROM `companies`ESC[0m
  ESC[4;36;1mCompany Load (0.4ms)ESC[0m   ESC[0;1mSELECT * FROM `companies` WHERE (`companies`.`subdomain` = 'slate') LIMIT 1ESC[0m
Rendering template within layouts/application
Rendering home/index
  ESC[4;35;1mUser Columns (2.6ms)ESC[0m   ESC[0mSHOW FIELDS FROM `users`ESC[0m
  ESC[4;36;1mUser Load (0.4ms)ESC[0m   ESC[0;1mSELECT * FROM `users` WHERE (`users`.`id` = '2') LIMIT 1ESC[0m

domain.com/users

Processing UsersController#index (for 24.20.194.187 at 2009-09-03 15:24:03) [GET]
  Parameters: {"action"=>"index", "controller"=>"users"}
  ESC[4;36;1mCompany Columns (2.6ms)ESC[0m   ESC[0;1mSHOW FIELDS FROM `companies`ESC[0m
  ESC[4;35;1mCompany Load (0.4ms)ESC[0m   ESC[0mSELECT * FROM `companies` WHERE (`companies`.`subdomain` = 'slate') LIMIT 1ESC[0m
  ESC[4;36;1mUser Columns (2.7ms)ESC[0m   ESC[0;1mSHOW FIELDS FROM `users`ESC[0m
  ESC[4;35;1mUser Load (0.4ms)ESC[0m   ESC[0mSELECT * FROM `users` ESC[0m
Rendering users/index
  ESC[4;36;1mSQL (0.2ms)ESC[0m   ESC[0;1mSET NAMES 'utf8'ESC[0m
  ESC[4;35;1mSQL (0.2ms)ESC[0m   ESC[0mSET SQL_AUTO_IS_NULL=0ESC[0m

application.html.erb [edited element contents]:

Oh right. less than greater than. suffice it to say, it has the html, head, and body tags, with a <%= yield %> statement.

+1  A: 

First confirm that the only file in views/layouts is application.html.erb, then double check your UsersController and make sure that any line specifying the layout is removed.

Andy Gaskell
I did the second part, and I *thought* I did the first part. I put all the scaffolded layouts into a *sub* directory thinking that rails wouldn't notice them. I moved the subdir up a few levels and *voila* it works.Thank you *so* much! I knew I'd find an answer here, and I knew I'd bang my head against the wall when I heard the answer and say "Duh"!Excuse me, I must commence with the banging and the "doh"ing.
Elizabeth Buckwalter
So, do you think that when you declare a root in routes that rails looks specifically for layouts/application.html.erb instead of layouts/home.html.erb? That seems to explain why home worked.
Elizabeth Buckwalter
By convention Rails will try to match the layout with its controller, if nothing matches then application will be used. If you're using scaffolding you probably won't need a new layout for every controller - I'd just delete the new layouts when you run scaffolding.
Andy Gaskell