Forum: Ruby on Rails 3 different areas, 1 yield?!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fdb488647484e40f785dde7134afc6d1?d=identicon&s=25 Heinz Strunk (cojones)
on 2008-10-22 17:35
Hello,

I'm having a problem which is following:
<div id="header"><img ...></div>
<div id="navigation">[STUFF FROM THE DB]</div>
<div id="submenu">[STUFF FROM THE DB]</div>
<div id="content"><%= yield  %></div>
<div id="footer">[STUFF FROM THE DB]</div>

How can I fill the [STUFF FROM THE DB] div's when I only have one single
yield? I can't think of any possible solution...
36aef9956c6082f69622dd67e8da376f?d=identicon&s=25 Joshua Abbott (joshnabbott)
on 2008-10-22 18:03
I'm not sure but guessing these things may change on a per-template
basis. If so content_for may be what you're looking for:

http://railscasts.com/episodes/8

You could also use a partial to pull this off.

-- Josh
http://iammrjoshua.com

Heinz Strunk wrote:
> Hello,
>
> I'm having a problem which is following:
> <div id="header"><img ...></div>
> <div id="navigation">[STUFF FROM THE DB]</div>
> <div id="submenu">[STUFF FROM THE DB]</div>
> <div id="content"><%= yield  %></div>
> <div id="footer">[STUFF FROM THE DB]</div>
>
> How can I fill the [STUFF FROM THE DB] div's when I only have one single
> yield? I can't think of any possible solution...
Fdb488647484e40f785dde7134afc6d1?d=identicon&s=25 Heinz Strunk (cojones)
on 2008-10-22 18:14
Yep! Thanks a lot.
Fdb488647484e40f785dde7134afc6d1?d=identicon&s=25 Heinz Strunk (cojones)
on 2008-10-22 19:01
One more question arose that Google and the search couldn't answer:
One of these div's have the very same entry no matter what page is being
loaded therefore I'd need have:

<% content_for :footer do %>
  <%= render :partial => "shared/footer" %>
<% end %>

in every view and this is not very DRY. Is there any possibility to make
it DRY?
D6434aa0b7b350f8c3ed0119d81b2ead?d=identicon&s=25 Roy Pardee (rpardee)
on 2008-10-22 20:55
(Received via mailing list)
That should go into your layout (apps/views/layouts).
Fac81a9d95c81d817a2debb6f717f3ac?d=identicon&s=25 Sazima (Guest)
on 2008-10-23 17:06
(Received via mailing list)
Heinz,

You should really take a look at this:

http://www.railsdev.ws/blog/3/modular-page-assembl...

Cheers, Sazima

On Oct 22, 1:35 pm, Heinz Strunk <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.