# What is the matter with content\_for\_layout?

**URL:** <https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271>\
**Category:** Rails\
**Created:** [March 13, 2006, 12:11pm UTC](https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271 "2006-03-13T12:11:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tauraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/47e85d/32.png) [@Tauraus](https://www.ruby-forum.com/u/Tauraus)\
**Post date:** [March 13, 2006, 12:11pm UTC](https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271/1 "2006-03-13T12:11:27Z")

</div>

Here is my layout file:

 My Demands \<%= stylesheet\_link\_tag 'ajax\_scaffold', :media =\> 'all' %\> \<%= javascript\_include\_tag 'prototype', 'effects', 'rico\_corner', 'ajax\_scaffold' %\>
\<%= @content\_for\_layout %\>

After I start up the Webrick server,the html source will be as follows:

 My Demands 
 My Demands 
...

It seems that @content\_for\_layout will contain all the content include  
the part before ,how can it happen? very thanks!

---

<div class="post-metadata">

**Author:** ![Tauraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/47e85d/32.png) [@Tauraus](https://www.ruby-forum.com/u/Tauraus)\
**Post date:** [March 13, 2006, 12:20pm UTC](https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271/2 "2006-03-13T12:20:27Z")

</div>

Most likely you have that content in your .rhtml files too

Tauraus wrote:

> It seems that @content\_for\_layout will contain all the content include  
> the part before ,how can it happen? very thanks!

---

<div class="post-metadata">

**Author:** ![Tauraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/47e85d/32.png) [@Tauraus](https://www.ruby-forum.com/u/Tauraus)\
**Post date:** [March 13, 2006, 12:28pm UTC](https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271/3 "2006-03-13T12:28:56Z")

</div>

Cheltis wrote:

> Most likely you have that content in your .rhtml files too
> 
> Tauraus wrote:
> 
> > It seems that @content\_for\_layout will contain all the content include  
> > the part before ,how can it happen? very thanks!

I had examined other rhtml file for times,but it does not exist at all…

---

<div class="post-metadata">

**Author:** ![Tauraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/47e85d/32.png) [@Tauraus](https://www.ruby-forum.com/u/Tauraus)\
**Post date:** [March 13, 2006, 1:34pm UTC](https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271/4 "2006-03-13T13:34:01Z")

</div>

Tauraus wrote:

> Cheltis wrote:
> 
> > Most likely you have that content in your .rhtml files too
> > 
> > Tauraus wrote:
> > 
> > > It seems that @content\_for\_layout will contain all the content include  
> > > the part before ,how can it happen? very thanks!
> 
> I had examined other rhtml file for times,but it does not exist at all…

I got the reason,but I still do not know how to resolve this problem.  
It is because of my using pagination.  
Here is the demands\_controller:

def index  
end

def list  
@pages = Paginator.new self, Demand.count, 10, @params[:page]  
@demands = Demand.find(:all, :order =\> ‘reply\_times DESC’, :limit =\>  
10, :offset =\> @pages.current.offset)  
end

Here is the index.rhtml:  
\<%= render\_component :controller =\> ‘demands’, :action =\> ‘list’ %\>  
it is generated by the Ajaxscaffold.

if the url refers to : [http://127.0.0.1:3000/demands](http://127.0.0.1:3000/demands) or  
[http://127.0.0.1:3000/index](http://127.0.0.1:3000/index)  
then the above error will happen  
if the url refers to : [http://122.0.0.1:3000/demands/list](http://122.0.0.1:3000/demands/list)  
then everything is ok

Can anybody tell me the reason? very thanksful!

---

<div class="post-metadata">

**Author:** ![Tauraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/47e85d/32.png) [@Tauraus](https://www.ruby-forum.com/u/Tauraus)\
**Post date:** [March 13, 2006, 2:05pm UTC](https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271/5 "2006-03-13T14:05:16Z")

</div>

Cool,aha! Thanks a lot,Cheltis 🙂

Cheltis wrote:

> OK, now it looks clear
> 
> layout is dublicated because it applied twice
> 
> you should put something like this in your controller  
> layout “your\_layout”, :except =\> ‘list’
> 
> however, correct way of doing this would be removing index.rhtml and  
> changing index action to
> 
> def index  
> list  
> render :action =\> ‘list’  
> end

---

<div class="post-metadata">

**Author:** ![Tauraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/47e85d/32.png) [@Tauraus](https://www.ruby-forum.com/u/Tauraus)\
**Post date:** [March 13, 2006, 1:59pm UTC](https://www.ruby-forum.com/t/what-is-the-matter-with-content-for-layout/80271/6 "2006-03-13T13:59:29Z")

</div>

OK, now it looks clear

layout is dublicated because it applied twice

you should put something like this in your controller  
layout “your\_layout”, :except =\> ‘list’

however, correct way of doing this would be removing index.rhtml and  
changing index action to

def index  
list  
render :action =\> ‘list’  
end

Tauraus wrote:

> I got the reason,but I still do not know how to resolve this problem.  
> It is because of my using pagination.  
> Here is the demands\_controller:
> 
> def index  
> end
> 
> def list  
> @pages = Paginator.new self, Demand.count, 10, @params[:page]  
> @demands = Demand.find(:all, :order =\> ‘reply\_times DESC’, :limit =\>  
> 10, :offset =\> @pages.current.offset)  
> end
> 
> Here is the index.rhtml:  
> \<%= render\_component :controller =\> ‘demands’, :action =\> ‘list’ %\>  
> it is generated by the Ajaxscaffold.
> 
> if the url refers to : [http://127.0.0.1:3000/demands](http://127.0.0.1:3000/demands) or  
> [http://127.0.0.1:3000/index](http://127.0.0.1:3000/index)  
> then the above error will happen  
> if the url refers to : [http://122.0.0.1:3000/demands/list](http://122.0.0.1:3000/demands/list)  
> then everything is ok
> 
> Can anybody tell me the reason? very thanksful!
