Semergence

Seth Ladd’s blog about Ruby on Rails and crunching data.

Lesser Known Rails 2.2 Features

leave a comment »

With Ruby on Rails 2.2 released, no doubt you’ve seen the major feature overviews. But did you know there are lots of subtle improvements? Pathfinder Development has a nice summary at Rails 2.2 For Me And For You.

My favorite new feature that I didn’t know about:

Also, partials now take blocks, meaning they can act somewhat like layouts.

The partial itself can contain a yield:

   <table>
     <tr><td>
       <%= yield %>
     </td></tr>
   </table>

Then the call to the partial can include a block:

<% render :partial => "table_partial" do %>
  <%= @project.name %>
<% end %>

And the yield command invokes the block, as you would expect

Awesome!

Written by sethladd

November 22, 2008 at 2:43 pm

Posted in rubyonrails

Leave a Reply