Rails 1.2.2: SQLite3, gems, singular resources

It’s time for another minor update to Rails 1.2. This was primarily prompted by a change in the API for SQLite between version 3.3.7 and 3.3.8+, which left the Rails database adapter for dead by the road side. But with this release and Jamis Buck’s sqlite3-ruby gem at version 1.2.1, we’re back in business on all versions of SQLite3.

Second, we’re now depending on RubyGems 0.9.0 and above. This will fix the deprecation messages for require_gem (the new method is just gem) and will restore rake rails:freeze:gems to working order. So be sure to update to the latest RubyGems before installing. That’s done with “gem update —system”.

Finally, we’ve decided to throw in a few goodies along with the fixes described above and the rest of the bug reparations in this release. Singular resources, for example, allow you to model singleton resources within the scope of the domain. The common example is user.application.com/account. That’s now modeled with:

map.resource :account

…and routes accordingly:

GET /account => AccountController#show GET /account/new => AccountController#new GET /account;edit => AccountController#edit POST /account => AccountController#create PUT /account => AccountController#update DELETE /account => AccountController#destroy

Note that the controller is also singular, not plural as is usually the case when using map.resources.

We’ve also brought over the enhancement to :conditions in Active Record that’ll allow you to pass in ranges and get them automatically converted to BETWEEN statements. Like:

Student.find(:all, :conditions => { :grade => 9..12 })

…which then becomes:

SELECT * FROM students WHERE grade BETWEEN 9 AND 12”

This is a recommended upgrade for everyone running 1.2.x (and a reminder that if you’re not yet on Rails 1.2.x, you won’t be getting bug fixes automatically and have to backport them yourself). It’s a drop-in replacement requiring no changes to applications running 1.2.×.

Enjoy!

RailsConf is more than half sold out and the fastest selling O'Reilly conference

The registration form for RailsConf is still glowing hot after a weekend that ensured that we’re now more than half sold out for the conference! This makes RailsConf ‘07 the fastest selling conference that O’Reilly have been involved with.

If we continue with this rate, we’ll be sold out before the end of the week. That’s 1200 seats. Not too shabby for a framework not even three years old and a conference only in its second year.

It’s going to be an amazing festival in Portland, that’s for sure. I can’t wait to get up there and talk about Rails 2.0.

Joyent makes Rails app go to 4,000 req/sec

Our friends at TextDrive/Joyent have been slugging away at their seriously impressive mega-cluster for quite some time now and it looks like it’s paying off. Just a few days ago, Shopify announced they were coming over.

And now Jason Hoffman shares a few statistics on how they’re making a new big Rails app scale to no less than 4,000 requests per second on one of their sub-pages. That’s a pretty juicy number and is thanks to their BIG-IP-to-48-mongrels setup for Twitter.

Keep rocking, boys.

BTW, the company’s Jason Hoffman will be giving a 3-hour tutorial at RailsConf entitled Scaling a Rails Application from the Bottom Up. You’d be well-advised to secure an early seat to that one.

New Feature for Rails 2.0: Multiple Controller View Paths

Thanks to John Long, Rails now supports multiple view paths for each controller. For 90% of the apps, this probably won’t make a huge difference. But, for those of you wanting to productize various open source apps, you can now do this:

/beast/trunk$ mkdir vendor/plugins/test_view_paths
/beast/trunk$ cd vendor/plugins/test_view_paths
/beast/trunk/vendor/plugins/test_view_paths$ mkdir views
/beast/trunk/vendor/plugins/test_view_paths$ echo “ActionController::Base.view_paths.unshift File.join(directory, ‘views’)” > init.rb

What you’ve done is created a minimal rails plugin that inserts a ‘views’ directory in the plugin to the beginning of the #view_paths array. Now, copy a view from the rails app into the plugin’s ‘views’ directory, make a noticeable change, and start your app. You’ll notice that it picked your plugin’s view over the application’s view.

How to get more literal URLs and still use IDs

Obie walks through the technique for getting more search engine-friendly URLs and still retain the ease of use with auto-incrementing ids.

It’s the same technique we used on the new 37signals blog engine to get urls like http://www.37signals.com/svn/posts/247-calling-all-basecamp-customers-in-nyc-or-chicago.

The 247 is what Rails see and calling-all-basecamp-customers-in-nyc-or-chicago is what Google will focus on. Have your cake and eat it too!

Capistrano 1.4.0

Capistrano is a utility for executing commands in parallel on multiple machines, such as for automating the deployment of applications. Version 1.4.0 is now available.

To install:

gem install capistrano

Version 1.4.0 fixes a few bugs, and adds a few features. The new features:

  • A “capture” helper has been added, to make it easy to capture the stdout of a remote command and return it as a string:
result = capture(“uptime”)
  • A “get” helper has been added, to mirror the “put” command, letting you easily download files from a remote server to the local host. It will only download from the first server that matches the criteria for the current task. You must have Net::SFTP installed (gem install net-sftp) in order to use the “get” helper.
get “#{current_path}/log/production.log”, “logs/production.log”
  • Support for a system-wide config file has been added. If a file exists in “/etc/capistrano.conf”, it will be loaded immediately after the standard recipe file is loaded, and immediately before any user-specific configuration.

The fixed bugs:

  • There used to be issues with cap hanging when running multiple capistrano instances at the same time when using gateways. This has been fixed.
  • The permissions tweaking in the standard recipe has been refactored into a separate task (set_permissions), which you can override if you are on a host that won’t let you set group-writable permissions.
  • The setup task now uses umask so that intermediate directories are created with the proper permissions.
  • Make sure the standard recipe loads first, so that .caprc and friends can oerride what it defines.
  • cold_deploy now calls update instead of deploy, to avoid invoking the restart task.
  • The ‘touch’ command in update_code now sets TZ to UTC for the duration of that command, so that asset timestamps are set correctly.
  • An off-by-one bug in the width computation for show_tasks has been fixed.

Minor deprecations:

  • The c/-caprc switch has been removed, since the new load order (standard, system, user, application) makes it meaningless.

Thanks to Mark Imbriaco, Neil Wilson, Bojan Mihelac, Joshua Wehner, and Mike Bailey for their contributions to this release.

One third of RailsConf '07 seats gone!

So we had a suspicion that the seats for RailsConf ‘07 would sell fast, but this is ridiculously. A few hours after we’ve opened for registrations that close to more than a third of the seats for the conference would be gone. At this rate we might well sell out the conference even faster than last year.

RailsConf '07 opens for registration

Come May 17th, the Oregon Convention Center in Portland will host the second annual RailsConf and if you want to be there, you better get your registration in early. Last year the 600 seats were gone in a week and change.

We’ve doubled capacity this year, but the growth of Rails has shot up even faster than that. So if you want to be sure not to miss out, I’d advise you skip reading the rest of this introduction and jump straight to the registration form.

This year we’ve teamed up with O’Reilly to produce the conference, which means that silly-nilly details like which sessions will be available are actually ready for you to peruse before signing up. This goes for the new-to-this-year first day of tutorials too. What a luxury treat. And on top of sessions and tutorials, we’ll of course also have a slew of keynotes.

It’s going to be one heck of a show. I can’t wait to see your all there.

Getting that Rails Deployment Help

As hosts start expanding their hosting options, it’s becoming more important for folks to get together and share their deployment knowledge and trade war stories. Robby Russell thought it was time, and started a rails-deployment Google Group, as well as #rails-deployment on Freenode. In just a short time, it’s already attracted nearly 400 members, including experts from some prominent rails hosts like PLANET ARGON, Engine Yard, and Rails Machine.

JRuby enters the home stretch for Rails support

We’re on the home stretch now, and Rails is getting more and more solid every day. With you all helping, we should be able to finish off the remaining failures, clean up major outstanding JRuby issues, and kick out a pretty sweet “Rails-supporting” JRuby release in the next couple weeks. — Charles Nutter

I’m not a Java guy by any means, but I don’t think anyone disagrees that this is great news. Why? The idea of dynamic languages on the JVM is very appealing, even Ryan Tomayko thinks so.

Now, being a recovering C# programmer, I had no idea how to get JRuby installed and running. So, here’s a quick newbie guide for you Mac OSX users. If you have good instructions for other platforms beyond what’s in the JRuby blog, please post or link to them in the comments. Also, be sure to use the proper reporting channels for any bugs you come across: the Rails Trac for Rails bugs, and JRuby’s JIRA for JRuby issues.

  • First, you need java. Luckily, it happens to ship with Tiger. “java -version” tells me I have v1.5.0_06. Awesome.
  • I actually set this up over the weekend, and used ‘ant test’ to build and test JRuby. This required me to install JUnit to proceed. I just created a directory to act as my CLASSPATH, and threw junit-4.1.jar in there.
  • Set up a few environment variables (see below for the list).
  • Add /path/to/jruby/bin to your PATH.

export CLASSPATH=/path/to/junit-4.1.jar
export JRUBY_HOME=/path/to/jruby
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
export JRUBY_SHELL=/bin/zsh

After this was done, I was able to run jruby or jirb directly. Depending on where you add the jruby/bin path, you may or may not be using the JRuby gem script or not. Use ‘which gem’ to check.

There you go, you should be all ready to help the JRuby folks out.