5th Rails book announced (2nd from O'Reilly)

Robby Russell has announced his authorship of an upcoming book that’ll provide “… an in-depth look at RoR, how it works inside and out”. The book is to be published by O’Reilly. This will then be their second Rails book (they’re already doing a Developer’s Notebook) and the fifth book in total announced for Rails. What awesome news!

Hopefully we can get a nice mesh of complimentary books out of all these announcements. We’ll want the imminent sea of uptake to acquire the entire shelve of Rails book at the book store. Not worry about choosing.

Rails 0.12.1: No major update without a bit of pain

There’s nothing like pushing a new major update in order to find bugs in the code when its exposed to a couple of hundred working applications. Thankfully the fixes were almost as swift as the reports. In any case, you’ll definitely want to upgrade to 0.12.1 right away. There’s a good handful of fixes for both Action Pack and Active Record (mostly concerning the new eager loading).

Here’s the dirt, so you don’t have to go look it up. First for Action Pack:

  • Added xml_http_request/xhr method for simulating XMLHttpRequest in functional tests #1151 [Sam Stephenson]. Example: xhr :post, :index
  • Fixed that Ajax.Base.options.asynchronous wasn’t being respected in Ajax.Request (thanks Jon Casey)
  • Fixed that :get, :post, and the others should take a flash array as the third argument just like process #1144 [rails@cogentdude.com]
  • Fixed a problem with Flash.now
  • Fixed stringification on all assigned hashes. The sacrifice is that assigns[:person] won’t work in testing. Instead assigns[“person”] or assigns(:person) must be used. In other words, the keys of assigns stay strings but we’ve added a method-based accessor to appease the need for symbols.
  • Fixed that rendering a template would require a connection to the database #1146

Then for Active Record:

  • Fixed frivilous database queries being triggered with eager loading on empty associations and other things
  • Fixed order of loading in eager associations
  • Fixed stray comma when using eager loading and ordering together from has_many associations #1143

Updating, as always, couldn’t be easier than gem install rails --include-dependencies.

Rails 0.12.0: Eager associations, new Base.find API, assertions revisited, more Ajax!

The time had come to butcher the piggy-back query and introduce real association loading through outer joins. Behold, the glorious eager loading of associations that makes it silly easy to fetch not 1, 2, but unlimited associations alongside any record in a single query. Turning 50 database queries into 1 never felt this good.

# Turning N+1 queries into 1
for post in Post.find(:all, :include => [ :author, :comments ])
  puts "Post:            " + post.title
  puts "Written by:      " + post.author.name
  puts "Last comment on: " + post.comments.first.created_on

And to match the eager loading, we’re introducing a brand new unified API for Base.find, which works the same whether you’re searching for a specific id, the first record, or all the records. By using named options we alleviate your poor brain for remembering whether the ordering option was argument number 3 or 4.

Person.find(1, :conditions =>"administrator = 1", :order =>"created_on DESC")
Person.find(1, 5, 6, :conditions =>"administrator = 1", :order =>"created_on DESC")
Person.find(:first, :order =>"created_on DESC", :offset => 5)
Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
Person.find(:all, :offset => 10, :limit => 10)

Better testing
We’ve also slashed the huge number of assertions for testing controllers. In one fell swoop, we’ve gone from around thirty to a shap seven. The remaining assertions are more flexible than before, not nearly as hard to remember, and are followed on by the fantastic new assert_tag, which makes examining the HTML output of an action so much easier than the XHTML/REXML fumblings of yesterday.

More Ajaxing
Of course, we couldn’t make a new release without asserting the undisputed position as the number one framework for doing Ajaxed applications. This release contains a bunch of new smooth effects for visualizing your non-refreshing actions. It’s now much easier to make Ajaxed applications that treat the unfortunate without Javascript nicely with request.xml_http_request? and alternative targets for ajax links and forms. We’ve also added periodically_call_remote that can be used to Ajax-update a given block every so seconds.

In the next release, which will be not very far off, we’re also adding awesome support for both Google Suggest-like search boxes and for upload progress indicators. There’s a powerful team behind pushing the envelope on this. We have so not seen the end of it.

A total of 96 changes, tweaks, and fixes
All these goodies are just the tip of the iceberg, though. There’s a total of 96 new features, changes, tweaks, and fixes packed into this monster of a release. And we didn’t even have time to push in all of the pending patches. How’s that for an action-packed three weeks since the last release?

Fully backwards compatible!
Despite the true onslaught of new features, fixes, and goodies, we’ve managed to keep this release fully backwards compatible with 0.11.1. So you just do a “gem update rails” and all the new stuff is available for use in your current application (to take advantage of the new JS effects you’ll want to copy that one over, though — use rails . in your app dir to get that for free).

See the changelogs for the full story:

Rails Day: Make an application in 24 hours and win!

Since Rails is supposedly this über-productive bag of lightning bolts, you should be able to accomplish great things within a single clip of 24 hours, right? That’s the assumption Rails Day is setting out to prove. A competition to build something meaningful, cool, neat, and/or beautiful that’ll be judged by a panel of experts including yours truly and Dave Thomas.

There’s even a great give-away happening. The best applications can win an Apple Mac Mini (courtesy of the ever-fantastic TextDrive— are you signed up yet?), an iPod Mini from the crew at Odeo, 6 books from the Pragmatic Bookshelf, lifetime Basecamp basic subscription, and more. It’s a true shower of gifts.

The whole shebang is going down on June 4th. Read more at Railsday.com.

Portland Rails presentation draws full house

Lucas Carlson talks about how Portland is turning into a power zone for Rails development and how great his presentation there went last night:

Last night I gave a presentation about Rails to what was supposed to be the local Perl mongers and Ruby group. Usually, between 6-10 people show up to either meeting, so I was expecting 20-25 people. But Rails pulled people out of the cracks and the turnout was around 50 people.

Overall, the crowd seemed very happy and excited, many oooos and ahhhhs. A lot of people emailed me afterwards saying that they were planning on starting their first Rails sites.

You should get involved with your local Java, Perl, Python, or PHP user groups too. Let the rhetoric take a back seat for a little while and show your fellow programmers what it is we have here in Ruby on Rails land. No reason hoggin all the tool toys for yourself. Sharing is so much more fun.

RForum 0.1 sees the light of day

RForum is one of the earliest open source applications based on Rails, but it has only just reached a state where the authors Andreas Schwarz and Alexey Verkhovsky were willing to share with the world. Hence, the release of RForum 0.1.

Congratulations on the release. With the project out in the open, we’ll hopefully more rapid improvement towards a 1.0 release.

Instiki 0.10.0 comes on the Rails

Alexey Verkhovsky has completed the transition of Instiki to a Rails-based core that uses the latest versions of all the framework instead of the ‘03 dialects it was currently running. Instiki is still powered by Madeleine, though. Which means that it’ll be some time yet before you can run Instiki on Apache or lighttpd directly as a move to Active Record or a separate Madeleine process is needed for that to happen.

The new version should be a lot more approachable for Rails hackers, though. And its also a pretty good case of how to use Rails with something else than a database backend. Dig in!

Contrasting scaling in J2EE and Rails/FastCGI

Jon Tirsen has taken a closer look at the differences between the threaded scaling approach in J2EE and using Rails with FastCGI. While the former requires object pools, induces thread-safety concerns, and other complications, the FastCGI approach remains dead simple from the application programmers perspective:

This means that each process can pre-allocate one single database connection (for each database that it talks to). There are no issues of multi-threading as each process processes only one request at a time. No objects needs to be written to handle multi-threading, as there is just one single thread per process. Expensive resources doesn’t need to be allocated in pools and application code doesn’t need to return the resources once done with them. Complicated non-blocking IO solutions or muxer/demuxer architectures doesn’t need to be used. You can even allocate FastCGI processes on multiple physical nodes, effectively implementing a cluster. In high-security situations a double-firewall security architecture can be set up so that the web-server is protected by one and the back-end FastCGI servers are protected by an additional one.

A peek at the additional Ajaxing coming in 0.11.2

The pursuit of Ajax nirvana with Rails is marching ahead with breath-taking haste. Thomas Fuchs has compiled a demonstration page of all the effects that we’ve added to the package. Web applications are soon going to be hot on the heels of the GUI goodness we’ve grown accustomed to with OS X.

But not content to show of the effects, Thomas has also recorded two impressive movies demoing the upcoming support for both auto-completion form fields and for an upload progress bar (which he has been working on together with Sean Treadway).

Thomas has been a driving force behind most of the new effects and the two fantastically cool abstractions of complete approaches. Are you looking to hire someone to inject the good mood of Ajax into your application? Then Thomas is at the forefront of that pack.

Read more from him on his weblog mir.aculo.us.

Allowing developers to use the tools they love

Hank Roar is the customer on a project being developed by ThoughtWorker Obie. He’s quite pleased with the progress:

Never under estimate the importance of allowing developers to use the tools they love. I don’t personally know Obie well, but I think he feels passionate about Ruby and Rails. This, coupled with the fact that the simulators will not go to my ultimate users, has resulted in the simulators being fun to use, not just simple data entry forms. The executive sponsor was very impressed with the simulator. I think the sponsor really enjoyed how much fun it was to use.