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

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!!!

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

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
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs