As David Heinemeier Hansson already told us all during his RailsConfEurope 2007 keynote, it’s time to take off the party hats. It’s no longer at time to celebrate all the new stuff we get. It’s time to celebrate what we have already.
With this statement DHH ends the revolution of Rails. During the past three years a lot of new and exiting features were added to Rails. However, now the time has come to evolve Rails further. No more new and exiting stuff, but fine tuning. Making things even better than they already are.
So, Rails 2.0 will not contain any major new features. But don’t despair, there are quite a few nifty changes that you’ll like to know about.
1. HTTP Authentication
HTTP Authentication is a great way to limit access to specific areas of your application that regular users won’t access. It might even be a good second layer of security for your administrator interface. Rails 2.0 will include easy methods to get HTTP authentication working for you.
2. HTTP Performance
The performance of a web application goes down the drain when you add too much JavaScript and stylesheets. Each and every file must be downloaded separately. Rails 2.0 will be able to take all the javascript files, stuff ’em together, compress that one file and sent that to the client, where it will be cached.
<%= javascript_include_tag :all, :cache => true %>
<%= stylesheet_link_tag :all, :cache => true %>
3. Asset Server
If you have a large (and busy) site, serving static files can be quite a performance issue. Rails 2.0 adds the notion of an “asset server”. An asset server (in combination with item #2) will serve static content quickly, allowing your app to respond even faster to a user’s request. To enable asset hosts, add the following line to your configuration:
config.action_controller.asset_host = 'assets%d.example.com'
You can even cycle through multiple asset servers by simply creating the appropriate CNAME records in DNS. Neat, eh?
3. The Debugger
“The Debugger” is here! Simple add ‘debugger’ to your app, and it will stop just there for you to step in and debug your application. This is a very powerful way debugging your apps quickly and with ease.
4. Query Cache
Query Caching is something that normally happens in a database server, not now. ActiveRecord keeps a cache of queries and uses it when the same query is made again. You don’t have to worry about anything, not even expiring your cache, because this is done automatically when you insert, update or delete any data that’s related to the cache.
5. Environment Configuration
If you have ever developed a serious Rails application, you know that your environment.rb can become a mess very quickly. Rails 2.0 allows you to split up your configuration into multiple files to keep things clean. (And you can also reuse your common configuration files for other apps as well.)
6. ActionTemplate Renderer
Say good bye to the trusty old rhtml and rxml files! There are new conventions for templates that will tell you more about what type of file the generate and which parser is used to render the templates.
Normal HTML views will get the .html.erb extension from now on (formerly .rhtml). If you want to build an XML file with “Builder”, you would use: template.xml.builder.
7. Sexy Migrations
Sexy Migrations have been around for some time as a plugin. Some people love them, others don’t. I still have my doubts about it, but at least it’s less code to write, and it keeps things more readable, which is good, I guess.
Let’s take an old migration:
create_table :people do |t|
t.column :first_name, :string, :null => false
t.column :last_name, :string, :null => false
t.column :group_id, :integer
t.column :description, :text
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
We now have this:
create_table :people do |t|
t.integer :group_id
t.string :first_name, :last_name, :null => false
t.text :description
t.timestamps
end
8. Plugin Mania
A lot of methods/features have been deprecated in Rails 2.0. Some non-core components like in-place editing have been moved to separate plugins. You will also find plugins like resource_feeder and open_id_authentication. Let’s hope that OpenID finally takes off now.
9. Thou shalt use MIT
This one I hadn’t heard at the keynote, but had to read it on the internet.
“Due to licensing confusion for people using plugins, the new plugin generator now creates a license file by default. The assumption is that you are distributing under the MIT license otherwise you have to modify the file to meet your needs."
I think Rails 2.0 will be quite a nice. Apps will be a bit more manageable and performance will be better also. Now, it’s just waiting for DHH to release the “2.0 Preview Release” he promised.