Rails 0.11.0: Ajax, Pagination, Non-vhost, Incoming mail

With the inclusion of Ajax helpers in Rails 0.11.0, we’ve addressed the most important concern holding back large scale Ajax use: Writing DHTML by hand. Manipulating the DOM by hand is a labor-intensive and error-prone process rife with frustration and cross-browser compatibility. With the Ajax support in Rails, writing manual Javascript/DHTML is (almost) a thing of the past.

Through a handful of helper tags, we’ve exposed an approach that relies on a bare minimum of support on the client-side (XMLHttpRequest and innerHTML) while offloading the generation of page fragments to familiar constructs like ERb and Builder templates. This means that you’ll build your Ajax integration using all the tools you’re familiar with and safely let the Javascript/DOM magic be off-loaded to the Rails helper and library.

Sam Stephenson (hire this guy!) has been the architect behind transforming my meager Javascript attempts into a fully object-oriented library that the Rails helper calls to do its dirty work. He has also done a video demonstrating how he can turn a create form into Ajax in just a few minutes. While this may appear a bit complicated, its mostly because the application Sam’s integrating with lets the controller generate the URL, which normally isn’t the case.

While the Ajax support is certainly the star of this release, we have much more. Another Sam Stephenson goodie is Pagination support, which lets you seamlessly spread the results of a list across multiple pages by combining controller-side and view-side support for pages and navigation.

Also of note is that Rails applications no longer require their own virtual host to be easy to setup. It’s now possible to symlink the public directory from underneath an existing hierarchy, so your application can live under hieraki in /community/hieraki. This should make it considerably easier to install and distribute applications that need to live on shared servers. If you want to make your own application vhost agnostic, have a look at the AssetTagHelper that’ll automatically create the proper paths for images, stylesheets, and the likes.

The Action Mailer gained inbound capabilities in this release. By implementing the receive(email) method, you can target your Action Mailer from fx postfix and have it process incoming emails. We’ve even enhanced TMail to make it easy to process international emails (auto converting to UTF-8) and handling file attachments. See the example in the README and checkout the Howto.

On top of all that there’s a new script/runner for making it easy to call your Rails domain model from CRON, there’s a new Flash module, there’s database indifferent limit/offset, and a truckload of fixes, enhancements, and tweaks.

See all the changes in the changelogs for Rails, Active Record, Action Pack, Active Support, Action Mailer, and Action Web Service.

Updating: If you’re coming from Rails 0.10.1, just run rails . --skip in the root of your application to get the new files. You shouldn’t need to change any code. You will need to clear out all your sessions, though, because of the Flash module upgrade!

RubyConf 2005 preregistration is open

Let me tell you where you’re going to be on October 14th through 16th. You’re going to be in San Diego, California. That’s right. RubyConf just opened the doors for the preregistration (which incidentally is a Rails app by David Black) and I managed to grab the entry with ID = 1 in the database. So you know I’m going to be there. Are you?

4th book coming: Rails Developer Notebook

O’Reilly is getting on board the Rails too. Their first book is going to be the Rails Developer Notebook, which as the name suggests is part of their Developer’s Notebooks series:

The Developer’s Notebook series is for early adopters of leading-edge technologies who want to get up to speed quickly on what they can do now with emerging technologies. If you’re a coder down to your core, and just want to get on with the job, then you want a Developer’s Notebook. Coffee stains and all, these books are from the minds of developers to yours, barely cleaned up enough for print.

The book is being coauthored by Bruce Tate (Bitter Java, Bitter EJB, more) and David Geary (Core JavaServer Faces, Core JSTL, more). The writing is supposed to start in April and the book should be out by June. So the focus is definitely to get something short out early and quickly.

If you’ve been following Rails advocacy, you may remember the name David Geary. I ripped into him fiercely about a month ago as he quickly dismissed Rails as being nothing but a CRUD scaffolder and declared “…you take this ROR koolaid. I’ll stick with the JSF flavor”.

Luckily, it didn’t take much more than two weeks for Geary to reconsider the dismissal and commit to looking closer at Rails. And now just a month later, he has signed on with Bruce Tate and O’Reilly to write a book about Rails!

What a fantastic and inspiring transformation. Hopefully Geary can serve as a role model for other Java developers who are feeling “…a bit nervous about this ROR thing”. Despite being heavily vested with Struts, Tiles, JSF, and Shale, he was able to see that there was amble room for a competing stack and jumped on to it.

My warmest welcomes to the Rails world, Geary! I wish Bruce Tate and you the best of luck with the Rails Developer Notebook and can’t wait to read it.

New book coming: Pragmatic Rails Recipes

I’m incredibly proud to announce the third Rails book in the making. The title is “Pragmatic Rails Recipes: A Guide to Elegant Web Development” and the authors should be very familiar to the Rails community: Marcel Molina (noradio) and Scott Barron (htonl). They’ve been around since the first release and are both integral parts of the Rails community through their programs, writing, and help on IRC.

The publisher is Dave Thomas’ progressive Pragmatic Bookshelf. The same umbrella that’ll carry the first Rails book to be published, Agile Web Development with Rails. This will of course ensure that the two books will become very complimentary and that they’ll both be available in my favorite reference book format: PDF.

It’s still very early in the process, the signatures on the contract is hardly dry, so the release target is tentative at best. Never the less, Scott and Marcel are aiming at October of this year. That’ll give the three books current announced a nice spread. Dave’s book around July, this one around October, and the German book around December/January.

That’s of course not to say that we can’t fit more books into the calendar. Quite the contrary. And from the handful of offers I’ve been getting from various authors and publishers, I’d be quite surprised if we didn’t see at least a couple of more Rails book announced this year.

Exciting times indeed.

Scott also talks about the book today.

RubyGems 0.8.8 with better dependency management

I forgot to mention that a new and much improved version of RubyGems was made available a while back. The new version makes it a lot easier to install Rails with all of the dependencies thanks to the added --include-dependencies option and you can cleanup older versions of Rails with the new cleanup command.

The RubyGems team also started using Hieraki to do documentation. Checkout RubyGems Manuals.

Bruce Perens' glowing ode to Rails

When Bruce Perens first showed up at the #rubyonrails IRC channel, we were honored by his presence. Bruce is a thought leader on free and open source software and the series editor of Bruce Perens’ Open Source Series from Prentice Hall. He’s also an avid Ruby on Rails convert and asked me to post this endorsement here:

In 1981, when I started working on Unix, I remember being blown away by the power of the command-line pipes-and-filters paradigm. You could get real work done with simplicity, clarity, and economy of notation that wasn’t available in anything else at the time. I’ve worked with lots of programming environments since then, but none of them gave me that feeling of being able to write a solution so well that working code just flew off of my fingers. Until now: Ruby on Rails achieves for web programming the same sort of conceptual leap that Unix made for file-handling. You’ve got to try it!

As one who rarely misses an opportunity to tout the Rails horn, this is almost too kind. Thanks so much, Bruce!

Bla-bla List: Cloning a Rails app in RIFE

Geert Bevin gets an A+ for trying, no doubt about that. In an attempt to hold the fort for Java as the troops are deserting left and right, Geert went away for a few months to contemplate and implement Bla-bla List. A more or less functional clone of Ta-da List done in Laszlo and RIFE (a Java web framework).

With the introduction of Bla-bla, Geert was even so kind as to point out a few security and usability issues with Ta-da, which was promptly resolved. Even kinder, he has put up a Subversion repository with the full source.

I gave it a glance and decided to share a few snippets from Ta-da (which unlike Bla-bla is not open source) to show the difference in how the two implementations deal with the core action: checking off todo items.

While no comparison between two different implementations is going to be perfect, this is as close as it gets. What surprised me the most was the lack of a real domain model. Apparently, the model in Blabla is just a bunch of data containers while the logic is in a service/controller layer. Ouch. I sure don’t hope that procedural excuse for an object-oriented system is par for course with RIFE.

Regardless, this was surely good fun. Geert put a lot of effort into it and a pat on the back for that. Whether this implementation is going to lure any of the deserters back into the camp is more doubtful, though.

P.S.: Geert’s posting includes a doomsday warning that data will be lost on Ta-da if your session expires. That was true for about half an hour, but has since been resolved.

'Ruby on Rails hurts developer productivity'

I tried to warn him, but he wouldn’t listen. Jakob Skjerning, who helped redesign rubyonrails.com and whom I worked with on Daily Rush, has been sucked into the Rails vortex:

After having gotten used to RoR for a private project or 2, all the web development stuff I do at work feels ugly, clunky and unproductive, simply because I am not using Ruby on Rails for it.

So take my advice: If you are stuck doing legacy work on a legacy system, don’t think about learning RoR – you might never want to go back to work if you do.

So let that be a warning to all of the prospect Rails programmers out there. Be careful what you get started with.

We actually have a thread on feeling dirty about not doing Rails on the mailing list right now. Rick Olson writes:

Going back to ASP.Net development makes me feel dirty. What? I have
to update the stored procedure, the model, the DAL, the form, and
create a new server control just to add a property???