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.
Heinz S. (Guest)
on 2008-10-22 19: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...
Joshua A. (Guest)
on 2008-10-22 20: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 S. 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...
Heinz S. (Guest)
on 2008-10-22 20:14
Yep! Thanks a lot.
Heinz S. (Guest)
on 2008-10-22 21: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?
Roy P. (Guest)
on 2008-10-22 22:55
(Received via mailing list)
That should go into your layout (apps/views/layouts).
Sazima (Guest)
on 2008-10-23 19: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 S. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.