Rails for Strut-ters: Dealing with the view

Brian McCallister is doing an excellent job showing Strut-ters how Rails work by comparing it to their own environment. In this round, he’s taking a look at the oh-horror that is unleashing a real programming language on view logic. He finds that perhaps it’s not so bad at all comparing:

<% for invite in @invitations %>
<% end %>

…from Rails to the JSP approach of tag libraries with:

<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<logic:iterate name="invite" property="invitation">

Indeed they do look similar. For more on that discussion, read my views on template languages and why the scriplet approach works in Rails.

As a sidenote, I’d like to suggest a few improvements to the tag/value mix that Brian has in his examples. For example, we could convert:

&lt;form action="<%= url_for :action => 'register', :controller => 'rsvp' %>">  
   &lt;input type="text" 
          name="invite_names[&lt;%= slot %>]" 
          length="30"&lt;%= "value='#{@invite.split_names[slot]}'" %>/>

To use a few more succinct FormTagHelper helper methods:

&lt;%= form_tag :action => 'register', :controller => 'rsvp' %>
&lt;%= text_field_tag "invite_names[#{slot}]", @invite.split_names[slot] %>

But that’s nitpicking. Brian is doing a fabulous job expressing the unknown in familiar terms. If you’re in need for something more visual on the Helpers, see this video demonstrating how to create a helper method in Rails.

What if I could just use Ruby on Rails...

Jaikoo wonders what the world would look like if he could just develop purely in a dynamic environment:

One of the things I’m currently working on is this massively complex J2EE application running on JBoss. The thing I still can’t get used to is bouncing Apache (thats running a full blown Rails app). I mean it starts from cold in like 3 seconds on my live server. That can’t be right? After all JBoss 3.2.3 takes around 5 minutes to startup on the equivilent server. Yes, I know I’m comparing apples with oranges, but sometimes I just wonder how much more productive I’d be if I developed purely in dymanic languages such as Ruby or Python.

Of course, during development you don’t even have to restart anything to see your changes instantly reflected. It’s change’n’reload, baby.

Odeo is launching on Rails

Evan Williams (of Blogger fame) and friends have unveiled their latest venture: Odeo. It’s going to make “…it easy for you to discover, create, and subscribe to fresh, independent audio content for your iPod”. In short, Portal for Podcasting. That hook got the interest of The New York Times, but to get the full story, you’ll be well advised to read Evan’s blog posting about it and the Odeo blog in general.

I had a sneak peak at the application a few days ago and it looks mighty cool. I’m a big fan of podcasting myself (especially from the ever excellent ITConversations), so the prospect of Odeo makes me pretty excited.

What also makes me excited is Odeo running Ruby on Rails. Remember that posting Evhead advertises for a Rails developer back in the beginning of December? That resulted in the hiring of Rabble as the lead developer on Odeo. He talks about the Odeo launch and how they “…built it with the wonderful Ruby on Rails framework” in his blog.

So congratulations, guys! It’s great to see another high-profile site launch on Rails and loving it. Keep ’em coming.

Rails 0.10.0 is a Ruby 1.8.2 framework

It’s time to upgrade to Ruby 1.8.2, folks. Rails 0.10.0 includes various bits that require this version of Ruby, so if you want to run the latest Rails, you’ll have to get on the latest Ruby too. You’ll be glad you updated anyway. Ruby 1.8.2 contains a year’s worth of fixes, additions, and goodies from the Ruby masters. It’s an insult to them if don’t get jiggy with the goods (and Rails developers have other things to worry about that testing across old Ruby versions). Oh, when you upgrade, be sure to patch test/unit.

Joyent seeks 4 developers with Rails experience

David Young from the San Francisco start-up Joyent are looking for 4 developers with Rails experience:

We’re looking for four exceptional people, they should have deep experience writing good GUI applications and/or understand the integration of various open-source server products including mail, calendar, directory, samba, and rails. Some experience with Mozilla’s XUL is a big plus (it’s a bigger plus if they understand why XUL isn’t a complete solution). We will provide relocation (and visa, etc. sponsorship) assistance, but relocation is not necessary for the first phase. If desired, relocation would happen in the September, 2005 timeframe.

If you’re interested, get in touch with david at joyent dot com.

Rails 0.10.0: Routing, Web Services, Components, Oracle

We’re plowing through the road map at lightning speed with the release of Rails 0.10.0. There’s so much good stuff in here this time it’s really hard to pick just a few bits to focus on for the overview, but still I have. With Rails 0.10.0, you’ll get:

  • Routing: Pretty URLs of all flavors and fashions can now be specified using an easy to understand Routing syntax made in Ruby. This means no more wrestling with mod_rewrite in Apache to get custom URL schemes. It means you’re not bound to the traditional /controller/action/id form (the controller and action names don’t even have to be part of the URL!). It also means that the URL parsing and generation is handled by the same configuration, which removes all the labor previously involved in getting your Ruby code to sync with your rewrite rules. That makes it possible to share the same URL configuration across all the web servers supported by Rails. You can seemlessly develop your application on WEBrick and without changes move it to Apache or lighttpd. Read more in the Routing book, see a bunch of routes explained, or dig into the ActionController::Base#url_for API documentation.
  • Web Services: Action Web Service is a whole new add-on framework for Action Pack that enables SOAP with WSDL and XML-RPC web services to be made with Rails ease. You can either describe an existing controller with an API, and let the clients interact with the same methods used to do the HTTP interface, or you can create dedicated service classes that can be bound to a controller. In addition to the support for building web services, we’ve also added convenient wrappers for calling other web services from your application. For getting started, there’s a whole book on Action Web Service that explains how to define, implement, and interact with the web serivce APIs. We also got examples using the GoogleSearch API and the metaWeblogApi.
  • Components: With components it’s possible to call other actions and controllers for their rendered response while executing another action. You can either delegate the entire response rendering or you can mix a partial response in with your other content. This makes it possible to package functionality in reusable parts and to keep more DRY on application elements that integrate from many sources (like a dashboard). To learn more about components, we have another book, a video showing how to make and call components, and the API docs.
  • Oracle: In addition to the existing adapters for MySQL, PostgreSQL, SQLite, SQL Server, and DB2, we now also support Oracle as a database option for Active Record. The adapter that made it in is built on top of OCI8 and has been confirmed to work great with Oracle 8i and 9i. Our sixth database adapter is documented in the API.

But there’s a world of additional new and fixed stuff in 0.10.0. See the other whole new package Active Support and check the changelogs for Rails, Active Record, Action Pack, and Action Mailer.

Honoring Nicholas Seckar and Leon Breedt

The two most important features in this release has been contributed to two relative newcomers to the Rails scene. Nicholas Seckar tried at least three attempts at Routing before we found the one that felt like the best Rails fit. He put an enormous amount of energy into sorting out all the complications and have since helped to improve all parts of Rails. You’ve done a superb job, Nicholas. May potential employeers looking for talent see your name.

Equal thanks goes to Leon Breedt that popped out of nowhere with a whole new framework that followed our established conventions and approach to the dot. The quality of the code and documentation has made a big impression on the existing team of core contributors. And the work has contributed to make us all the much closer to 1.0. Thanks for the excellent work, Leon!

So how far away is Rails 1.0?

Rails 1.0 moved much closer today as we knocked off well over half of the previously announced road map. What we primarily lack now is Packaging and Performance alongside the aim to bring the number of uninvestigated and/or fixed fault tickets down to zero. The current tentative date is end of March/start of April.

Upgrading from Rails 0.9.5 to 0.10.0

If you don’t have any custom URLs defined in your existing application, then it’s a fairly straight forward process to upgrade. If you do have custom URLs, it’s a bit more work, but definitely manageable. Basecamp used a lot of custom URL tricks and it took me under an hour and resulted in 100 lines of code being stripped from the application. In any case, we’ve created a book to guide the upgrade process.

'They won't ever fit together like Rails'

Matt Grayson is another Python programmer that despite his love for Python “…haven’t done much Python lately”. He blames Rails, which he declares “…is worth the hype.”. On the prospect of seeing Python on Rails, he offers:

The closest thing I’d found to Rails in Python is a combination of CherryPy, SQLObject and Cheetah. But as much as I like each one of those pieces individually, they won’t ever fit together like Rails – which is why I don’t have a lot of optimism for things like Subway. I’ve got nothing against Subway. Could they pull it off and put together a really good Python web framework? Sure. But, given the track record of past attempts at web frameworks within the Python community, I won’t hold my breath.

And Jake from Maui is yet another Python programmer that has been getting into Ruby through Rails:

Every time my work took extra time, it’s because I was expecting a level of complexity that wasn’t there. Wow. It’s not often that one of the tools I use humbles me, but finally I’ve found something that allows me to write code as fast as I think.

Soo many quotes, so little space

Xavier Defrang characterizes himself as a “…a frustrated Python-lover writing object-oriented PHP code”. He has contributed to the O’Reilly Python Cookbook and initiated the french translation of Dive Into Python. Despite his pythonic love, he has also managed to post the single most flattering article about Rails I’ve yet to stumble across in which he compares Ruby on Rails to Java, Python, and PHP.

The number of quotes and passages I want to pull out are so plentiful that I can hardly decide. Here goes a few:

  • The recent Trails video walktrough just showed that J2EE zealots were definetly not getting it: the What is as important as the How
  • I consider myself a real Pythonistas… and I’ve never thought of Ruby as attractive because of its syntax I (still) find a bit too sweet… But now that there is a killer app for Ruby which appears to square the circle of web development, can you think of a better time to look at it?
  • I predict that a lot of high-profile PHP developers will soon or later switch to RoR. As a frustrated Python-lover writing object-oriented PHP code, Rails really fits as the best-of-both-world solution.
  • The productivity boost offered by Rails is similar to what I experienced when switching from C++ to Python as my main development language. Everything is so simple and natural that it feels just like your own framework you would have grown yourself after years of trials and errors.

Anyway, go read the whole thing before I reveal all of it through quotes. It’s either a man who really gets it or a terrible suck up. Depending on your own personal enthusiasm about Rails :)