# Layouts in Rails 3.0

**URL:** <https://www.ruby-forum.com/t/layouts-in-rails-3-0/194613>\
**Category:** Rails\
**Created:** [September 8, 2010, 1:52am UTC](https://www.ruby-forum.com/t/layouts-in-rails-3-0/194613 "2010-09-08T01:52:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhaagmans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jhaagmans](https://www.ruby-forum.com/u/jhaagmans)\
**Post date:** [September 8, 2010, 1:52am UTC](https://www.ruby-forum.com/t/layouts-in-rails-3-0/194613/1 "2010-09-08T01:52:15Z")

</div>

Hi,

I’ve just started my first Rails 3 stable app from scratch and still  
looking at all the changes. Most things are wonderful. However, I  
can’t figure out what happened to the layout structure.

In my controller:

class ApplicationController \< ActionController::Base  
protect\_from\_forgery

layout ‘application’  
end

And in app/views/layouts/application.html.erb:

 ... ... \<%= yield %\> ... 

This is the way I did it in Rails 2.3.x. I can’t find what’s changed  
in Rails 3.0. All my actions are showing up without the layout.

Thanks.

Jaap H.

---

<div class="post-metadata">

**Author:** ![jhaagmans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jhaagmans](https://www.ruby-forum.com/u/jhaagmans)\
**Post date:** [September 8, 2010, 3:48am UTC](https://www.ruby-forum.com/t/layouts-in-rails-3-0/194613/2 "2010-09-08T03:48:42Z")

</div>

On Sep 7, 5:51 pm, jhaagmans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> ...
> <%= yield %>
> ...
> 
> ```
> 
> This is the way I did it in Rails 2.3.x. I can’t find what’s changed  
> in Rails 3.0. All my actions are showing up without the layout.

Make sure you don’t have two application.\* files in the layouts  
directory. If for example you have:

layouts/application.html  
layouts/application.html.erb

It will render the .html.erb first.

Also, look at the log to see what they say. Did your old  
application.html.erb get renamed during the upgrade?

Anyway, hope this helps.

---

<div class="post-metadata">

**Author:** ![jhaagmans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jhaagmans](https://www.ruby-forum.com/u/jhaagmans)\
**Post date:** [September 8, 2010, 11:18am UTC](https://www.ruby-forum.com/t/layouts-in-rails-3-0/194613/3 "2010-09-08T11:18:16Z")

</div>

Hi James,

Thanks for your thinking with me.

I haven’t upgraded from Rails 2.3.x, I’ve started a new Rails 3  
application and edited the generated application.html.erb. I’ve also  
tried creating a new one called main.html.erb and pointing to that in  
my ApplicationController, but that didn’t work as well.

The logs show nothing weird:

Started GET “/user\_sessions/new” for 127.0.0.1 at Wed Sep 08 11:14:27  
+0200 2010  
SQL (0.4ms) SHOW TABLES  
Processing by UserSessionsController#new as HTML  
Rendered user\_sessions/new.html.erb (7.0ms)  
Completed 200 OK in 70ms (Views: 20.2ms | ActiveRecord: 0.4ms)

Thanks again.

Jaap H.

---

<div class="post-metadata">

**Author:** ![jhaagmans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jhaagmans](https://www.ruby-forum.com/u/jhaagmans)\
**Post date:** [September 8, 2010, 6:01pm UTC](https://www.ruby-forum.com/t/layouts-in-rails-3-0/194613/4 "2010-09-08T18:01:45Z")

</div>

Jaap H. wrote:

> In my controller:
> 
> class ApplicationController \< ActionController::Base  
> protect\_from\_forgery
> 
> layout ‘application’  
> end

Yank the

layout ‘application’

statement and you should be fine. My out-of-the-generator Rails 3 app  
honors the application.html.erb without any such statement.

class ApplicationController \< ActionController::Base  
protect\_from\_forgery  
end

---

<div class="post-metadata">

**Author:** ![jhaagmans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jhaagmans](https://www.ruby-forum.com/u/jhaagmans)\
**Post date:** [September 8, 2010, 6:22pm UTC](https://www.ruby-forum.com/t/layouts-in-rails-3-0/194613/5 "2010-09-08T18:22:48Z")

</div>

Hi Ar,

Thanks!

I added that statement because my layout wouldn’t show. So with or  
without it, it makes no difference.

Regards,  
Jaap H.
