Living on the edge (of Rails) #4 – faster routes, easier form partials

In: Edge Rails|Open Source|Ruby|Ruby on Rails

23 Jan 2008

It’s time again for your weekly dose of what’s new in edge Rails. This weeks’ report covers changes from 14 Jan 2008 to 20 Jan 2008 (the day the Rails Envy podcast was recorded).

Route recognition is faster

Rails’ route recognition has been optimized and is significantly faster especially for applications using many resources (i.e. via map.resources in your config/routes.rb). Big thumbs up to Oleg Andreev (aka oleganza) who also wrote a detailed post about it. You can also find out more about how this works in the code comments.

Related changesets: and

render :partial and forms

Instead of doing:

<% form_for(:person) do |f| %>
  <%= render :partial => 'form', :locals => { :form => f } %>
<% end %>

you can now do:

<% form_for(:person) do |f| %>
  <%= render :partial => f %>
<% end %>

Convenient. This also works with your custom form builders:

<% form_for(:person, :builder => LabellingFormBuilder) do |f| %>
  <%= render :partial => f %>
<% end %>

The partial template rendered is then people/_labelling_form and the local variable in the partial is labelling_form.

Related changeset:

Callbacks refactored into ActiveSupport::Callbacks

All that duplicated callback code in ActiveRecord, ActionController::Dispatcher, and in test case setup and teardown methods have been extracted into the ActiveSupport::Callbacks module.

Less duplication means more robust code so yay!

Related changeset:

ActiveRecord test suite gets a makeover

The ActiveRecord test suite has become something of a maze jungle in recent times, with no clear hierarchy of how things are organize. It’s not that easy to find what you are looking for especially for newcomers trying to contribute to ActiveRecord. Thankfully, someone (John Barnette – the foxy fixtures guy) has stepped up and cleaned things up quite a bit. Fixtures, test cases, fixture models, etc. are now in their own directories and from looking at the directory hierarchy one should be able to know where to put what at a glance.

Related ticket:


* redirect_to nil no longer explodes (but raises a friendlier ‘cannot redirect to nil’ exception) (related changeset:

1 Response to Living on the edge (of Rails) #4 – faster routes, easier form partials


A Fresh Cup » Blog Archive » Double Shot #130

January 24th, 2008 at 11pm

[…] Living on the edge (of Rails) #4 – faster routes, easier form partials – The latest news from the cutting edge. […]