Verbose Logging

software development with some really amazing hair

T + S G I F R

Rails 3 Release Notes: What Does It Mean To You?

· · Posted in Software
Tagged with

The Rails 3 Beta got dropped a few days ago, and the release notes for Rails were put out a bit before that.

The list of changes is long; this is a big release. There's a lot to sift through, a lot to change to upgrade your existing application, and a lot to learn whether you are upgrading or starting a new app.

The big question is: WTF does all this mean to me?

Don't worry, I'm going to tell you. If you want to read the full release notes, go for it, and I recommend you do, but I'm just going to cover the stuff (in the same order that it's in the release notes) that has the bigger impact on you, the developer.

No config.gem, only Zool bundler

Bundler has been going for a while now, and they just released 0.9 (and 0.9.2 shortly after). Bundler is a generic ruby gem dependency system. Note I said ruby and not rails. It works on any ruby application; I'm using in on this blog (which is sinatra based).

Basically, you have to put all the config.gem stuff from your environment.rb file into a Gemfile in the root of your app. For my blog (which isn't rails, remember), it looks like this:

Not a big deal, and don't worry, you'll like the system more anyway. Like I said, it's a ruby system, not rails, so it's the same wherever you go.

Oh, and there's a plugin to do the work converting to the new syntax for you. Aren't you glad you work with ruby?

WTF does it mean? Less rails-specific system, better dependency resolution, and better vendoring of gems.

New routing syntax

The new syntax for routes basically makes the routes file look nicer. It makes a bit more sense, and you feel that warm fuzzy feeling when you write it.

Now, normally you'd probably have more routes, but as an example, those two routes handle creating a blog post. Doesn't the new way look much better. You like that, don't you?

You can do other fancy things, like easily map other rack applications to routes. Check out all the new hotness.

WTF does it mean? Prettier, more readable code, which means we all win.

Action Jackson View

Action View now has Unobtrusive Javascript Support and DHH tells why. Oh, and it's awesome. It means you don't need a hack to use jQuery instead of prototype; it just works. It also means that your HTML isn't filled with onclick="omg('hax');" stuff. Everything is nice, and unobtrusive. It uses HTML5 goodness to accomplish things, and we all love HTML5. Well, except for, you know, Adobe.

ActiveRecord Query Interface

This is the fun one. Pratik Naik has the goods on this one. Read it, trust me.

All this new query stuff looks scary at first, but the good stuff is packed into arel. Arel is a relational algebra (get it? arel? Bazinga!) and it treats database queries the way they should be treated, not like a drunken hobo that stumbled into your web application. Using arel results in a much better and cleaner way to generate SQL (or even No-SQL queries), optimize them, chain them, and then spit them out to a string to be sent to the database. Previous to arel, ActiveRecord was, as far as I know, a really complicated and specific string builder. It had power, now it has finesse.

WTF does this mean? Your queries, when you write them, should look better and make more sense. Queries should be able to be optimized better, lazily executed, and therefore your queries might end up faster, and your app should be faster too.

And it's so very sexy.

ActionMailer Awesomeness

ActionMailer performs like a controller now. There is a good write up over here that explains most of the good stuff.

They are in a nice location, namely 'app/mailers'.

They return nice Mail::Message objects.

What more can you want?

WTF does it mean? You'll be happier writing mailers, it'll make more sense, and the world will rejoice.

What else?

Most everything else is pretty awesome, but doesn't overly affect your day to day work when writing your rails app. ActiveRecord is cleaned up so you can add validations and callbacks to any ruby class. ActiveSupport is cleaned up so you can require something, and it pulls in its dependencies, versus having to explicitly require it yourself. ActionController is split up so you can make your own lean controller to handle actions that need to be fast.

Like I said, go read the full release notes. They cover all the new changes, and will hopefully prepare you for some awesomeness. Make sure to read the articles I linked to as well, since they have excellent information regarding the new stuff.


Sharing is Caring