Rails 0.9.3: Optimistic locking, dynamic finders, 1.8.2

Rails is now fully compatible with Ruby 1.8.2, which we advice all to upgrade to as soon as possible. It contains a year’s worth of bug fixes for Ruby, so it’s great finally to be able to use the new version with Rails. But that is not all we got in store for 0.9.3. A few of the highlights are:

  • Automated optimistic locking: Just add the field lock_version to your table and the associated class will be governed by optimistic locking that’ll raise an exception if a stale object attempts to save.
  • Dynamic finders: Finders like Person.find_by_user_name, Payment.find_by_amount, and even Person.find_by_user_name_and_password are now available with no code at all. Any column can be used and combined with other columns in the new dynamic finders.
  • MS SQL Server and DB2: Active Record now supports both Microsoft SQL Server (through ADO) and IBM’s DB2 databases.
  • MemCacheStore for sessions: You can now store sessions in Action Pack using Danga’s memcache technology.
  • Generators guard against reserved words: Not only will ./script/generate model Thread be denied, you’ll also get a list of synonyms pulled live from WordNet!

That’s just a small taste of the 35 changes, fixes, and features introduced with Rails 0.9.3. You can read the full story in the changelogs for Active Record, Action Pack, and Rails.

Upgrading from Rails 0.9.2 to 0.9.3

There’s only one change you need to make in order to have your application updated from 0.9.2 to 0.9.3. In the config/environments/production.rb and config/environments/test.rb, you need to change:

  ActionController::Base.reload_dependencies = false
  ActiveRecord::Base.reload_associations     = false

…to:

Dependencies.mechanism = :require

And in config/environments/development.rb, you need to change:

  ActionController::Base.reload_dependencies = true
  ActiveRecord::Base.reload_associations     = true

…to:

Dependencies.mechanism = :load

If you’re coming on from 0.8.x, you’ll need to go through the Upgrading to 0.9 manual.

blog comments powered by Disqus