Living on the edge (of Rails) #11

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

12 Mar 2008

This week’s report covers changes from 3 Mar 2008 to 9 Mar 2008 (the day the corresponding Rails Envy podcast was recorded).

Improve performance on :include/:conditions/:limit queries by selectively joining in the pre-query

This is another ActiveRecord performance boost related to the pre-loading any eager-loaded :includes mentioned previously. Basically what this patch does is to only join referenced tables when needed. It does this by checking the :conditions and :limit options to determine whether a table should be joined or can be left out and pre-loaded instead. You can find out more in tickets #9560 and #9497.

Credit goes to Gabe da Silveira (dasil003 on Trac) for this awesome performance patch.

Related changeset: http://dev.rubyonrails.org/changeset/8977

Better error message for type errors when parsing request parameters

Now when you pass an incorrectly formed request (e.g. GET, POST) parameter to your controller, it will raise an exception that includes a friendlier error message that indicates exactly what you passed to it. This is helpful when trying to debug whether you constructed your form correctly.

Contributors: Chad Humphries and matt.

Related changeset: http://dev.rubyonrails.org/changeset/8986

Make MimeResponds::Responder#any work without explicit types.

Here’s something I didn’t know: you can actually use any in your respond_to blocks as a catch-all response. E.g.

respond_to do |format|
  format.html do
    redirect_to :action => 'login'
  end
  format.any(:js, :xml) do
    request_http_basic_authentication 'Web Password'
  end
end

Contrary to its name, using ‘any’ actually requires you to pass a list of types to respond to. This has been enhanced now so that if you don’t pass any arguments, it’ll function as a real catch-all.

respond_to do |format|
  format.any do
    request_http_basic_authentication 'Web Password'
  end
end

Credit goes to Joshua Wehner for this patch.

Related changeset: http://dev.rubyonrails.org/changeset/8987

Add readonly option to has_many :through associations

Turns out the :readonly option for associations mentioned earlier was left out for has_many :through associations. This oversight has been fixed.

Thanks to Emilio Tagua for this bugfix.

Related changeset: http://dev.rubyonrails.org/changeset/8989

As usual, let me know of any inaccuracies or any suggestions you may have in the comments!

1 Response to Living on the edge (of Rails) #11

Avatar

A Fresh Cup » Blog Archive » Double Shot #164

March 13th, 2008 at 7pm

[…] Living on the edge (of Rails) #11 – Summary of another week in development land. […]