[ANN] Rails 0.12.0: Eager associations, new Base.find API, assertions revisited, more Ajax!

  • Thread starter David Heinemeier Hansson
  • Start date
D

David Heinemeier Hansson

The time had come to butcher the piggy-back query and introduce real
association loading through outer joins. Behold, the glorious eager
loading of associations that makes it silly easy to fetch not 1, 2, but
unlimited associations alongside any record in a single query. Turning
50 database queries into 1 never felt this good.

# Turning N+1 queries into 1
for post in Post.find:)all, :include => [ :author, :comments ])
puts "Post: " + post.title
puts "Written by: " + post.author.name
puts "Last comment on: " + post.comments.first.created_on
end

Read more:
http://ar.rubyonrails.com/classes/ActiveRecord/Associations/
ClassMethods.html (Scroll down to Eager loading of associations)

And to match the eager loading, we're introducing a brand new unified
API for Base.find, which works the same whether you're searching for a
specific id, the first record, or all the records. By using named
options we alleviate your poor brain for remembering whether the
ordering option was argument number 3 or 4.

Person.find(1, :conditions => "administrator = 1", :eek:rder =>
"created_on DESC")
Person.find(1, 5, 6, :conditions => "administrator = 1", :eek:rder =>
"created_on DESC")
Person.find:)first, :eek:rder => "created_on DESC", :eek:ffset => 5)
Person.find:)all, :conditions => [ "category IN (?)", categories],
:limit => 50)
Person.find:)all, :eek:ffset => 10, :limit => 10)

Read more:
http://ar.rubyonrails.com/classes/ActiveRecord/Base.html#M000226

Better testing
--------------
We've also slashed the huge number of assertions for testing
controllers. In one fell swoop, we've gone from around thirty to a shap
seven. The remaining assertions are more flexible than before, not
nearly as hard to remember, and are followed on by the fantastic new
assert_tag, which makes examining the HTML output of an action so much
easier than the XHTML/REXML fumblings of yesterday.

Read more: http://ap.rubyonrails.com/classes/Test/Unit/Assertions.html

More Ajaxing
------------
Of course, we couldn't make a new release without asserting the
undisputed position as the number one framework for doing Ajaxed
applications. This release contains a bunch of new smooth effects
(http://mir.aculo.us/demos/effects/demo1.html) for visualizing your
non-refreshing actions. It's now much easier to make Ajaxed
applications that treat the unfortunate without Javascript nicely with
request.xml_http_request? and alternative targets for ajax links and
forms. We've also added periodically_call_remote that can be used to
Ajax-update a given block every so seconds.

In the next release, which will be not very far off, we're also adding
awesome support for both Google Suggest-like search boxes and for
upload progress indicators (http://sean.treadway.info/demo/upload).
There's a powerful team behind pushing the envelope on this. We have so
not seen the end of it.

A total of 96 changes, tweaks, and fixes
----------------------------------------
All these goodies are just the tip of the iceberg, though. There's a
total of 96 new features, changes, tweaks, and fixes packed into this
monster of a release. And we didn't even have time to push in all of
the pending patches (http://dev.rubyonrails.com/report/3). How's that
for an action-packed three weeks since the last release?

Fully backwards compatible!
---------------------------
Despite the true onslaught of new features, fixes, and goodies, we've
managed to keep this release fully backwards compatible with 0.11.1. So
you just do a "gem update rails" and all the new stuff is available for
use in your current application (to take advantage of the new JS
effects you'll want to copy that one over, though -- use rails . in
your app dir to get that for free).

See the changelogs for the full story:

* Rails: http://api.rubyonrails.com/files/CHANGELOG.html
* Active Record:
http://api.rubyonrails.com/files/vendor/rails/activerecord/
CHANGELOG.html
* Action Pack:
http://api.rubyonrails.com/files/vendor/rails/actionpack/CHANGELOG.html
* Action Web Service:
http://api.rubyonrails.com/files/vendor/rails/aws/CHANGELOG.html
* Action Mailer:
http://api.rubyonrails.com/files/vendor/rails/actionmailer/
CHANGELOG.html
* Active Support:
http://api.rubyonrails.com/files/vendor/rails/activesupport/
CHANGELOG.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top