I love how so many conferences are recording their sessions. Paris on Rails is another of those conferences and they’ve recently published their recordings as both video and audio. Most of these sessions are in French, but Michael Koziarski did a great session on Rails Performance that’s in English and so was my iChat Q&A session.
December 6-December 12, 2008 Edition
Here’s your weekly roundup of the action out on the edge, where the code is exciting and sometimes even stable. There were only 32 commits this week; perhaps we’re going into a bit of year-end hibernation.
A couple of memory leaks got squashed this week. There was one that occurs in Rails 2.2 when you set
config.log_level = :warn (this fix has been applied to the 2-2-stable branch as well as to edge) and one that turns up when you call
reset_session in an around filter (this fix is on edge, and will be ported to 2.2 soon). commit commit
There was a bit of cleanup work on the application template feature that was introduced last week. This included support for installing plugins as git submodules, a couple of small cleanup items, and a rake task to apply a template to an existing application . With this task, you can now run
rake rails:template LOCATION=~/template.rb
And the changes indicated in the template will be layered on top of whatever code the project already contains.
A few more bits of the Rails infrastructure are now exposed to internationalization, including connectors in
Array#to_sentence and separators in Active Record validation messages . Also of interest to the international Rails community is a patch to add an
ActiveSupport::Multibyte::Chars#ord method to properly return the Unicode value of the first character in a string.
Odds and Ends
There’s a new version of the memcache-client (22.214.171.124) bundled with edge Rails. This fixes some bugs in the original 1.5 and adds better support for failover and timeouts. You can read more about it on the Lighthouse ticket commit
If you test a lot of view code that uses partials, you’ll be happy to know that
assert_template now takes a
:partial option that can look for them in the output directly. commit
And finally, there’s a patch that has not been applied to Rails yet, but that you might want to go look at in Lighthouse – it adds support for HTTP status code 418 so that Rails can conform to RFC2324 . I’m sure the core team would welcome further discussion of this change.
If you can read German and you develop with Rails you’ll be happy to know that it republik, the same company that also produces a Java, .NET, and PHP magazine, is about to release a Ruby on Rails Magazine called RailsWay.
The magazine is in print and will be out in Germany, Switzerland and Austria by December 17, 2008. For 2009 they plan to release six issues (in the German language), and I hear they’re planning on an English version, but no ETA on that. The content of the first issue includes:
- Getting started with Ruby on Rails
- AJAX and Rails
- RAILS 2.2 – what’s new
- IDE’s for RAILS
- Behaviour Driven Development
- Metaprogramming With RUBY
- RESTFull Web Services
- Featured Website: Qype.com
- Tips, Tricks, Performance & Security
A DVD comes with the magazine which includes tutorials, videos, free rails books, and a bunch of IDEs. The Editor in Chief is Michael Johann, who has done a great deal to promote Rails in Germany.
Phusion is on a roll today. Not only did we just get a new Passenger, they’ve also just dropped a new REE (the Ruby patches for copy-on-write) that includes 64-bit support as well as compatibility with OS X and Solaris. They’ve also fitted the excellent RailsBench patches from Stefan Kaes that allows you to tweak the GC settings in Ruby if you need to.
November 29-December 5, 2008 Edition
Rails 2.3 development is still continuing at a healthy clip. Here’s an overview of what’s happened this week.
Rails now incorporates Jeremy McAnally’s rg application generator. What this means is that we now have template-based application generation built right into Rails; if you have a set of plugins you include in every application (among many other use cases), you can just set up a template once and use it over and over again when you run the
rails command. Pratik Naik provided a thorough writeup of this feature over on his blog. commit
Even the venerable code used by Active Record to talk to databases can be improved, and we had a couple of improvements checked in this week. First, the SQL generated for preloading records in has_and_belongs_to_many associations has had an extra “AS” excised, which makes it work better with some databases. Also, we now have a
:having option on find (as well as on has_many and has_and_belongs_to_many associations) for filtering records in grouped finds. As those with heavy SQL backgrounds know, this allows filtering based on grouped results:
developers = Developer.find(:all, :group => "salary", :having => "sum(salary) > 10000", :select => "salary")
The tighter integration of Rails with Rack continues. This week saw the death of the venerable CGI processor within Rails, as well as the use of Rack to handle FCGI. There was also some refactoring down in the Rails tests to make them play nicer with Rack. commit commit
Configuration File Cleanup
Over the years, the default environment.rb file had gotten a bit cluttered with comments, random documentation, and settings that mot people don’t need. DHH took a few minutes to clean up the mess, and the current state of this file is much leaner. As part of the cleanup, session store configuration has been moved out to its own file. commit
No More Process Scripts
If you’re one of the (fairly rare) Rails developers who deploys in a fashion that depends on the inspector, reaper, and spawner scripts, you’ll need to know that those scripts are no longer included in core Rails. For Rails applications that are reployed with current alternatives like Passenger, these are just unnecessary baggage. But if you need them, you’ll be able to pick up copies via the irs_process_scripts plugin. commit
Odds and Ends
The fact that Rails checks for IP spoofing can be a nuisance for sites that do heavy traffic with cell phones, because their proxies don’t generally set things up right. If that’s you, you can now set
ActionController::Base.ip_spoofing_check = false to disable the check entirely. commit
ActionController::Dispatcher now implements its own middleware stack, which you can see by running
rake middleware. commit
Gem loading is smarter about missing dependencies. commit
auto_link now properly applies options (such as :target and :class) to generated e-mail links. commit
The Phusion team keeps blazing ahead with Passenger and improving it rapidly. They’ve just released version 2.0.5, which includes a few fixes and introduces compatibility with the Rack-based Edge Rails.
At 37signals, we’ve already switched over Ta-da List and are busy working on getting the rest of our suite running on Passenger. It’s just so much easier to deal with and the memory savings you get through REE are a nice cherry on top.
I keep getting a steady stream of success reports from all over the world as well. I’ve even read of a few people getting back into Rails development because Passenger finally took out the inconvenience of deploying.
It’s hard to argue with the usability. I’ve personally been setting up a new server running Ubuntu 8.10 and using Apache 2 with Passenger. The time it took me to go from a fresh install to a complete production setup was ridiculously low. There’s just so much less to worry about.
If you haven’t given Passenger a chance yet, now is definitely the time.
Yesterday was Thanksgiving holiday for US-based developers – but it certainly hasn’t looked like a holiday week in edge Rails. Things are moving fast, with some major changes afoot for version 2.3 of Rails.
The underpinnings of script/server have been simplified and rewritten somewhat. The explicit list of supported servers that used to be in script/server is gone. Instead, Rails now depends on the installation of Rack, and script/server goes through this – which means that Rails supports any server that Rack does.
Routing sees a couple of big changes this week. The
formatted_ route helpers are gone, in favor just passing in
:format as an option. This cuts down the route generation process by 50% for any resource – and can save a substantial amount of memory (up to 100MB on large applications, according to the Lighthouse ticket ) If your code uses the
formatted_ helpers, it will still work for the time being – but that behavior is deprecated and your application will be more efficient if you rewrite those routes using the new standard. Another big change is that Rails now supports multiple routing files, not just routes.rb. You can use
RouteSet#add_configuration_file to bring in more routes at any time – without clearing the currently-loaded routes. commit commit
Better support for engine plugins
The second routing change enables better support for Rails Engines: routing files in engines are automatically loaded and reloaded now (as are those in other plugins). Engines are getting some love other than routing. If your plugin has an app folder, then app/[models|controllers|helpers] will automatically be added to the Rails load path. There’s active discussion of just how this should work, and how much to pick up from the current engines plugins, so it’s likely we haven’t seen the last commits in this area. Engines also support adding view paths now. commit commit commit commit
Sensible backtraces for your tests
If you’re a fan of the Thoughtbot Quiet Backtrace plugin, which allows you to selectively remove lines from Test::Unit backtraces, you’ll be happy to find
Rails::BacktraceCleaner in core. This supports both filters (to perform regex-based substitutions on backtrace lines) and silencers (to remove backtrace lines entirely). Rails automatically adds silencers to get rid of the most common noise in a new application, and builds a
config/backtrace_silencers.rb file to hold your own additions. commit
Ruby 1.9 integration
A variety of commits continue the drive towards Ruby 1.9 and minitest compatibility. This should ensure that Rails 2.3 is ready to handle the latest Ruby underpinnings when it’s released. Those on the bleeding edge at the moment need to beware, though: one of the changes in edge Rails depends on a ruby-core patch that hasn’t yet been applied there. You’ll also (temporarily) need to pick up Jeremy Kemper’s fork of Mocha for MiniTest compatability as required by this commit .
Faster boot time in development mode with lazy loading/autoload
Jeremy Kemper and Josh Peek have been doing a ton of work on making sure that bits of Rails (and its dependencies) are only brought into memory when they’re actually needed. Check out the commits from November 23 for a bunch of lazy-loading changes. The core frameworks – Active Support, Active Record, Action Controller, Action Mailer and Action View – are now using
autoload to lazy-load their individual classes. This work should help keep the memory footprint down and improve overall Rails performance. commit commit commit commit commit
You can specify using the new
preload_frameworks option whether the core libraries should be autoloaded at startup. This defaults to
false so that Rails autoloads itself piece-by-piece, but there are some circumstances where you still need to bring in everything at once – Passenger and JRuby both want to see all of Rails loaded together. commit
Asset hosts get more flexible in edge Rails with the ability to declare an asset host as a specific object that responds to a call. DHH has supplied a sample project, asset-hosting-with-minimum-ssl , that demonstrates one good use for this functionality. commit
You can now configure the location of the helpers folder for a Rails application by setting
ActionController::Base.helpers_dir. This will be a boon in some unusual circumstances – the original use case is for building a Rails application that encourages extension via plugin rather than by altering the application itself. commit
Token generation for CSRF protection has been simplified; now Rails uses a simple random string generated by
ActiveSupport::SecureRandom rather than mucking around with session IDs. As a result, the
:secret options to
protect_from_forgery are deprecated and have no effect on edge. commit
While we’re on the subject of secrets, some people will find novel uses for
ActiveSupport::MessageEncryptor, which provides a simple way to encrypt information for storage in an untrusted location (like cookies). commit
from_xml no longer depends on XmlSimple. Instead, Rails now includes its own XmlMini implementation, with just the functionality that it requires. This lets Rails dispense with the bundled copy of XmlSimple that it’s been carting around. commit commit
As you probably recall, last week’s improvements included the renaming of application.rb to application_controller.rb. This week there’s a new rake task,
rake rails:update:application_controller to do this automatically for you – and it will be run as part of the normal
rake rails:update process. commit
Good news if you’re using
ActiveSupport::OrderedHash: it now implements
One more bit of core Rails is open to I18n: the units used by
number_to_human_size. If you’re maintaining a translation file, you need to add the
storage_units: [Bytes, KB, MB, GB, TB] to your translations. commit
Support for Rails components – which were famously called “a shining example of what happens when eagerness overtakes prudence” in Agile Web Development With Rails – is finally gone. If a couple of years of warning about this deprecation wasn’t enough for you, then it’s time to find an alternate solution at last. commit
Various files in /public that deal with CGI and FCGI dispatching are no longer generated in every Rails application by default (you can still get them if you need them by adding
--with-dispatches when you run the rails command, or add them later with
rake rails:generate_dispatchers). commit commit
Just a reminder: I’m not providing pointers to every single commit here, just trying to highlight things. This week’s edge changes actually included 136 commits from a wide variety of contributors.
The old 15-minute blog video was getting really long in the tooth, so it’s with great pleasure that I can present the new video made with Rails 2.2 and done by Ryan Bates. It really takes it all up a notch by showing the creation of a blog with comments, ajax, feed, api, admin interface, and more.
Ryan Bates is also the author of the wonderful Railscasts.com site that features video explanations on Rails features. It’s a fantastic resource and now properly recognized on the screencasting page.
I’ve also linked up the commercial Rails screencasters. The amount of material available for people interested in learning by video is simply staggering.
Rails 2.2 is finally done after we cleared the last issues from the release candidate program. This release contains an long list of fixes, improvements, and additions that’ll make everything Rails smoother and better, but we also have a number of star player features to parade this time.
Internationalization by default
The most important is that Rails now includes a full-on internationalization framework and that it’s pre-wired from start. The work of the i18n group has been very impressive and it’s great to see that Rails finally ships with a solution in the box that’s both simple and extensible. Great job, guys!
Stronger etag and last-modified support
We’ve also added much better support for HTTP validators in the form of etag and last-modified. Making it so much easier to skip expensive procesesing if the client already has the latest stuff. This also makes it even easier to use Rails with gateway proxies.
Thread safety and a connection pool
Josh Peek has added thread safety to Rails and Nick Sieger from JRuby worked on getting Active Record a proper connection pool. So now all elements of Rails are thread safe, which is a big boon for the JRuby guys in particular. For C Ruby, we still need a bunch of dependent libraries to go non-blocking before it’ll make much of a difference, but work on that is forth coming.
Ruby 1.9 and JRuby compatibility
Jeremy Kemper has been rocking on both Ruby 1.9 and JRuby compatibility. Rails 2.2 is fully compatible with both, but again, there might be supporting libraries and gems that are not. Again, lots of work is going into making everything else fully compatible as well.
Better API docs, great guides
Finally, the last big push has been with the documentation of Rails. Pratik’s docrails project has made immense progress. Not only are the API docs much improved, but we also have a whole new guides section generated from documentation that now lives with the source. A true community project with lots of contributors. I’m sure both those new and old to Rails will greatly appreciate the strong focus on documentation.
To read about all these features and more in details, checkout the Rails 2.2 release notes — another one of those guides from the docrails project.
How to install
As always, you can install Rails 2.2 through RubyGems. We now require RubyGems 1.3.1, so be sure to update that first:
gem update --system
Then you can install Rails:
gem install rails
If you’re updating an existing application, you can run
From all of us to all of you, we hope you enjoy this release. It’s a true pleasure to see Rails make such big steps forward once again. Dig in, have fun, and we’ll be back with Rails 2.3 with even more before you know it.