views:

22

answers:

0

I am trying to achieve something similar to what is shown in the Rails 3 documentation

"You can also yield multiple times in one layout and use block arguments to differentiate the sections."

<%# app/views/users/_user.html.erb &>
<div class="user">
  <%= yield user, :header %>
  Budget: $<%= user.budget %>
  <%= yield user, :footer %>
</div>

<%# app/views/users/index.html.erb &>
<%= render :layout => @users do |user, section| %>
  <%- case section when :header -%>
    Title: <%= user.title %>
  <%- when :footer -%>
    Deadline: <%= user.deadline %>
  <%- end -%>
<% end %>

refrence: http://api.rubyonrails.org/classes/ActionView/Partials.html

but when I try out this I get a error saying "no block given"

So I tried the example before the above one in documentation

<%# app/views/users/_user.html.erb &>
<div class="user">
  Budget: $<%= user.budget %>
<%= yield user %>
</div>

<%# app/views/users/index.html.erb &>
<%= render :layout => @users do |user| %>
  Title: <%= user.title %>
<% end %>

Even this one gives me the same error "no block given"

Has anyone tried to render a partial using layouts in rail3. Is this a bug ?