Are you running the final version of Ruby 1.8.2?

A fair number of people have been having problems with Rails 0.13 because it relies on behavior present in the final version of Ruby 1.8.2. That’s the one released on December 25th, 2004. You can check if you have the proper version by doing ruby -v, which should return “ruby 1.8.2 (2004-12-25)”.

If it doesn’t, you need to upgrade. Releases from before December 25th are beta releases that are not ensure to be compatible with Rails. In particular, there’s the session exception like:

NoMethodError: undefined method `new_session' for #CGI::Session:0x259f6c0

…or Proc errors like this:

code_generation.rb:68:in `dup': allocator undefined for Proc (NoMethodError)

Both tell, tell signs that your Ruby beta has exceeded its expiration date.

What's with this DoubleRenderError?

Another haunting feature of 0.13 is the DoubleRenderError. Jamis explains it purpose:

In order to understand why the DoubleRenderError was necessary, you need to understand something about the render and redirect_to methods that may surprise you. Many programmers expect a call to render or redirect_to to immediately cease execution of their action and return the result back to the browser. This is not the case in Rails. Unless you explicitly return after rendering or redirecting, your action will continue on its merry way as if nothing had happened.

Go read the full thing and you’ll go “ahhhh, thank heavens for DoubleRenderError!”.

Feeling the slowdown blues after going 0.13?

It’s somewhat ironic that we heralded Rails 0.13 as being a great move forward for the performance of Rails and then half the threads on the mailing list is about “Rails is sLOOOW!”. We’ve found the problems, though.

The first was with the MySQL/Ruby bindings, which called GC.start whenever MySQL#free was called. And we just put in MySQL#free in 0.13 to improve things after each select of rows. This caused the garbage collector to run every time you selected something. Doh!

The C-bindings didn’t have this problem, so it wasn’t discovered by the core team right away, and that was posed as the solution on the mailing list. Unfortunately, it’s not necessarily trivial to compile native bindings on all platforms (notably Windows), so having fast Ruby bindings was indeed important. They’re fast again, but if you upgraded to the C-bindings you can be happy that you’re even faster.

The second problem was that we plugged a big memory leak in development mode, but doing so caused a total of 8 runs through the so-called ObjectSpace after each action (basically iterating over all objects in the interpreter 8 times, eeks!). On big applications this could take a while. On Basecamp it took 2 seconds. After the fix went in where we just traverse the ObjectSpace once, it’s down to a comfortable 0.2 seconds (which is about 0.17 faster than it even was before the memory leak fix!).

Thus, Rails 0.13.1 is near forth coming. As in this weekend. If you cannot wait, and we certainly won’t blame you, there are new beta gems that consist purely of bug fixes. Upgrade with gem install rails --source --include-dependencies.

New Rails movie with sound and sugar

The original Rails movie left jaws hanging and had developers all over the world stepping through it in slow motion to take it all in. But that was then. Rails 0.5 looks almost primitive from the eyes of a developer working with Rails 0.13. It was high time to rectify both that, the lack of narration, and the notion that Rails is all about Scaffolding.

So allow me to present: The New Rails Movie! It’s 50% longer, but shows at least 150% more. And you get my enthusiastic whoops! speak from the Brazilian FISL 6.0 conference where the movie premiered:

Many thanks to Pablo for providing me with the sound from the conference and many thanks to Audacity for making it something you could listen to.

Ruby on Rails at Java Forum Stuttgart

Thomas Baustert and Ralf Wirdemann are working on the German book for Ruby on Rails and they’re also spreading the word around the country. Two days ago they did the Java Forum Stuttgart, which is a gathering of some 800 Java programmers. Ralf summarizes the feedback:

Our presentation was also well attended by more than 100 people. We got excellent feedback and many developers were impressed about the simplicity and less code of Rails application.

Very nice. It’ll be interesting to see if a similar reaction will be had at JAOO when I enter the lion’s cave.

Marcel Molina and Sam Stephenson forms Ionist

Marcel Molina and Sam Stephenson are both core developers of Rails and has been riding the express since the very first release of the framework. In that time, they’ve delivered countless Rails applications and of course contributed to the framework with both code, documentation, and spirit.

Ionist is their new company specializing in Ruby on Rails consulting and application development. If you’re looking to get a whole project done for you in Rails or already have a team that just needs some expert guidance, these guys are exactly what you’ve been looking for.

They’re currently accepting new projects, so hurry up. They blog at

Tim O'Reilly: 'Rails has taking the world by storm'

Tim O’Reilly responds to a concerned programmer that is pondering the relevance of Perl in the face of competition from PHP, Python, and the statics .NET/J2EE.

Tim concurs that other languages have been gaining rapidly while Perl hasn’t. And as the original question didn’t mention Ruby nor Rails, he takes the opportunity to present the O’Reilly perspective on the duo:

The other scripting language (in addition to Perl, Python, and PHP) that we’re paying a lot more attention to these days is Ruby. The Ruby On Rails framework has taking the world by storm, and has gone one up on PHP in terms of making database backed application programming a piece of cake.

Welcome to the era of quick’n’clean.

Agile Web Development with Rails leaves beta

Our very first book on Rails is leaving beta and is in the process of going into print. Agile Web Development with Rails is now ready in its final form as a PDF and it’ll be ready in paper in time for OSCON. That’s pretty damn rocking!

And Dave Thomas slipped in a special treat in the PDF version now available:

One of the things I really like about the new PDF is the code hyperlinks. The little [File nn] lozenges in the margins next to code extracts are now live hyperlinks to the corresponding source file up on our media server. If you want to see the full code corresponding to an example, click, and it appears in your browser. (And, of course, all the code is available as a tarball or zip file.)

So for the two of you out there reading that haven’t yet bought in, now is the time!

Nicholas Seckar makes the commit team!

He rose through the ranks of contributors quickly with the great implementation of Routes, but has since put his mark on so much more. Including the dependency management system and lots of other tricky parts of Rails. In the just released 0.13, he was single-handedly responsible for about a quarter of the patches going in.

Thus, I got sick of rarely-to-never having a finger to put on his patches and merely serving as a commit lackey. It’s due time that he was granted the ability to do so himself.

Please do welcome Nicholas Seckar of Toronto, Canada as the latest member of the commit team. He joins Jeremy Kemper, Jamis Buck, and myself.

Can you believe that this guy actually has availability in his calendar to take on new projects? It’s true. So if you’re looking to hire a freelancer that really knows Rails, this is a great opportunity. Write him at nseckar at gmail dot com.

Getting Things Done with Active Record

Mike Clark has a great article on how to dig deeper into Active Record by using acts_as_nested_set and find_by_sql. On the notion of using SQL in an OO model, he writes:

Some may think this breaks object purity. I think it’s just productive. After all, I know there’s a database under there, and SQL is incredibly powerful for querying relational data. Most of the time I’d rather not write SQL because I’m doing CRUD operations. In those cases, Active Record intervenes to boost my productivity. And when SQL is the best tool for the job, Active Record gets out of the way to let me be most productive.

I couldn’t agree more. SQL is not bad at all. Once you take out the repetition for the simple cases, you’re left with a very powerful query language for the hard cases.