Rails Training with Chad Fowler
We covered a lot of ground in the 3-day training course that we planned with Chad Fowler. Much of the material is still sinking in for most of us, but we gleaned a lot of really good information and tips from the event. Some highlights from the three days based on my notes:
- Blocks - Methods that accept blocks can use this construct to clean up after the fact. The File.open and open (as part of open-uri) both accept blocks to automatically close the stream when finished.
- Mix-ins - Using modules provides a handy way to re-use functionality inside different classes.
- RESTful development - This is a big area of interest for us especially since Rails 1.2 was just officially released last week. We're already looking forward to using the ResourceFeeder plugin with 'respond_to' to handle the RSS feeds we previously created by hand.
- Routing - Though the material we covered about named routes existed in Rails 1.1.6, many of us hadn't made full use of it yet – something that we will be leaning on more as we push for more meaningful URLs
- Testing - We're already actively using unit and functional tests (and have been for quite a while), but the intro to Selenium that Chad did really blew us away! We're planning to use the Selenium IDE plugin to Firefox to allow project managers to create their own regression test suites.
- Advanced ActiveRecord - Association scoping is extremely useful to us and promises to clean up our controllers by refactoring logic back into the models. Because of the "leaky abstractions" in Rails, we're now using Nathaniel Talbott's Query Trace plugin to see where we should be auto-loading associations.
- Debugging Tips - Since 'puts' doesn't work as you might think in your controllers and views, Chad gave a couple really useful tips: add a single 'raise' call in your controller to inspect the state of your app or drop a call to 'debug(var)' into your view. For more advanced debugging, we saw the full power of using 'script/breakpointer' to interact with controllers from an IRB console.
- ActionMailer - We've been using ActionMailer for a while to send out emails from web apps, but the process for reading incoming mail is shockingly simple (much less involved than my previous PHP solution).
- Performance - As we need to increase performance with Rails apps, we will now start looking at pushing session and fragment storage to memcached and pass off resource intensive processing to BackgrounDRb.
- AJAX - Besides looking at RJS, we were introduced to the observe_form and observe_field magic to create auto-updating displays (useful for live searching).