# \<%= yield :article %\>\<%= yield :agentur %\>

**URL:** <https://www.ruby-forum.com/t/yield-article-yield-agentur/146666>\
**Category:** Rails\
**Created:** [August 23, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/yield-article-yield-agentur/146666 "2008-08-23T21:28:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ec9cab/32.png) [@ramiz](https://www.ruby-forum.com/u/ramiz)\
**Post date:** [August 23, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/yield-article-yield-agentur/146666/1 "2008-08-23T21:28:12Z")

</div>

Hi i start my first project in ruby on rails and i dont know how to  
add to yields in one layout. i tried this but it dont works:  
folder strucur in view is:  
app/views/agenturs/index.html.erb  
app/views/articles/index.html.erb  
app/views/layouts/agenturs.html.erb  
app/views/layouts/articles.html.erb

file: app/views/layouts/articles.html.erb

# Link1 open article

\<%= yield :article %\>

# Link2 open agentur

\<%= yield :agentur %\>

Please help!!!

---

<div class="post-metadata">

**Author:** ![ramiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ec9cab/32.png) [@ramiz](https://www.ruby-forum.com/u/ramiz)\
**Post date:** [August 24, 2008, 10:58am UTC](https://www.ruby-forum.com/t/yield-article-yield-agentur/146666/2 "2008-08-24T10:58:12Z")

</div>

can nobody held me???  
in one layout i iry to have two yields. first is: \<%= yield :article  
%\> and second is:\<%= yield :agenturs %\>

the first yield works great because the layout file is view/layouts/  
articles.html.erb  
if i call the layout view/layouts/agenturs.html.erb then the second  
yield works fine.

in a browser the call looks like this: localhost:3000/articles or  
localhost:3000/agenturs

---

<div class="post-metadata">

**Author:** ![ramiz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ec9cab/32.png) [@ramiz](https://www.ruby-forum.com/u/ramiz)\
**Post date:** [August 24, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/yield-article-yield-agentur/146666/3 "2008-08-24T19:30:38Z")

</div>

You need to have in your view:

\<% content\_for :article do %\>  
stuff goes here  
\<% end %\>

In order to know what replaces:

\<%= yield :article %\>

in your layout. One thing that’s useful to know is that the view is  
rendered FIRST and then the layout is found and rendered. That’s why  
the \<%= yield %\> and \<%= yield :symbol %\> can find the right parts to  
insert.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
