December 8th, 2007 benhughes
Whenever I go to a bookstore I am sure to check out the Rails/Ruby section (constantly increasing in size!) for any new titles I may not be aware of. I was pleasantly surprised to find a new large Rails book that almost went unnoticed: The Rails Way by Obie Fernandez. I say almost went unnoticed because the book cover looks almost identical to The Ruby Way, so it’s easy to gloss over if you don’t look carefully.
It is easy to see by the sheer size that this book, weighing in at 850 pages, that it is very in-depth. The author explicitly states in the introduction that this is not a book for Ruby on Rails beginners. It was intended on being primarily an information-packed reference book for professional developers working with Ruby on Rails. The most appealing characteristic of the book is that it covers Rails 2.0, the first book to my knowledge that does.
After reading the book (it’s a long read!) I can definately say that this is a very valuable book for Rails developers. Typically after reading the Agile book, Rails developers end up craving knowledge of more advanced Rails techniques and plugins, and this book certainly delivers in this respect. Sprinkled throughout the detailed description of the Rails API are useful plugins, tips, and techniques that the author has come across in his development experience. Also included are many snippets of code from the Rails source code that help explain how key things work in Rails.
A full chapter outline is available online so I won’t bother duplicating that work, but let me point out a few areas of Rails that this book covers:
- Rails Environment and Configuration – explains the Rails boot process and the automatic class loader, as well as other things behind the scenes that make Rails tick – very interesting.
- New Rails 2.0 RESTful Routes – Covers some changes and enhancements to the RESTful routing features of Rails 2.0.
- Advanced ActiveRecord – Really gives detailed information about ActiveRecord, even briefly explaining the AssociationProxy class that masquerades as an Array for those has_many associations.
- Prototype Reference
- Selenium Testing
- RSpec
- Using subversion with Rails and piston
- Rails deployment with Capistrano
- Common production configuration setups
- Background processing with BackgrounDRb
- ActiveSupport Reference
The last few topics in particularly were mostly until now the realm of random blog posts online with no solid resource in print.
In short, The Rails Way is a must-have for any developer working professionally with Ruby on Rails. Far from being a programming resource only, it helps you become an all-around better developer by arming you with techniques, new plugins, and tools to improve your productivity. Targeted towards the advanced user, this book is packed full of information that will greatly improve your facility with Rails. Buy it today!
Posted in Book Reviews, Rails General | No Comments »
December 7th, 2007 benhughes
So today Rails 2.0 was finally released; it seems as though the Rails core team has been polishing this up for ages. I don’t think there’s a whole lot to get excited about. In short, Rails 2.0 gives you better opportunity to make use of best practices, such as using the will_paginate plugin instead of build-in pagination (Rails 2.0 drops pagination support from core). Support for RESTful development is much improved, allowing more flexible route declarations and finally dropping the annoying semicolon separator for the edit action: projects/1;edit.
One very cool feature that should better allow developers to present meaningful error messages to users upon exceptions is the new rescue_from class method in ActionController::Base, which allows you to specify an exception class to rescue and an action to call to handle the error.
A few of my dissapointments of Rails 2.0 is that my two most pressing present concerns with Rails were not addressed:
A cohesive way of managing “fixture-like” data in an application. While simple Rails applications can rely on fixtures just fine, real production applications are not quite this simple and may rely on different sets of data that distinguish between semi-permanent “application” data and true test data. Multiple this by the dimension of multiple deployment environments (staging, production) which each may require different sets of data. I typically end up writing my own rake tasks and duplicate the fixtures data for specialized uses. It would be nice to see Rails provide an effective and standardized mechanism for being more flexible with “fixture-like” data rather than forcing us to use one inflexible “fixtures” directory.
Using the :include class in ActiveRecord finders creates severe limitations on the type of data you can get back. There have been numerous situations where I’ve wanted to use :include to get an object tree populated from one query yet still return an aggregation result in the select clause. A perfect example is listing forum threads, showing the number of comments but also including the user data who posted the thread. This is currently impossible with ActiveRecord because the select clause cannot be used with the include clause.
I plan on talking more about these two main issues for me in future posts, hopefully soliciting some responses. I haven’t found anything that adequately addresses my concerns.
Ultimately Rails 2.0 is sprinkled with various small changes rather than a fundamental architectural shift. As a result, it should be fairly easy to upgrade existing applications to Rails 2.0 and would probably be a good idea to do so, especially to force yourself to abandon bad practices that Rails 2.0 is less tolerant of.
One piece of reading that I would highly recommend if you already are familiar with Rails 1.2 and want to get up to speed on Rails 2.0 is the Peepcode PDF available here. I’ve found some of the Peepcode screencasts to be annoying slow an drawn-out, but this PDF is a must-have, packed full with the information you want to know, and quick to read.
Posted in Rails General | No Comments »
December 2nd, 2007 benhughes
I’ve been wanting to start a Ruby on Rails blog for a while to document my experiences using the framework and engage with the community, but always felt I wouldn’t have enough time to maintain it. Today I decided to give in and begin RailsGarden.com.
So just about every developer working with Rails professionally has a life story culminating in total infatuation with the Ruby language and Rails framework; here’s mine:
Having starting programming at an early age with a continual and early interest in computers in general, I quickly latched onto web programming because of the relative ease and the potential to create something decent without a whole lot of work. I first dabbled in Perl and at one point developed a small data-driven e-commerce application that powered a very early version of www.rarenewspapers.com. Looking forward to the newer web technologies of the time, I began learning PHP and MySQL. Relational databases and techniques to structure and store data well has always intrigued me. To this day, modeling databases and advanced database structures are my specialty. I began doing some basic projects for a few clients online while still in high school. The projects I took on increased in complexity as I gained better design patterns and my own personal coding stuff. Most of these projects were for a company I am still deeply involved with, Digital Peach Interactive, based out of Georgia. I also dabbled a bit in Adobe ColdFusion and ASP.NET with SQL Server
My use of PHP to architect web applications culminated in the design and implementation of a large internal content management system used at Digital Peach, implementing advanced features such as a very sophisticated hierarchical category system for permissions and a workflow engine. Building this application with my boss was quite an experience and the data model ended up consisting of over 130 tables, including tables for some of our main modules.
Having done quite a bit with PHP and become pretty proficient in using it and MySQL to build data-driven applications, I wasn’t particularly “happy” with what I did and didn’t derive a lot of intellectual satisfaction out of building software in PHP. This all changed when I began to look at Ruby on Rails, a technology I very ignorantly ignored for so long. My first experience with RoR was viewing the standard make a blog screen cast and a few of the online slide shows. Though initially skeptical of the framework due to scalability and extensibility concerns (due to my superficial understanding), I decided to purchase the standard Agile Development with Ruby on Rails book. Reading this book was like a constant barrage of “aha!” moments, page after page. It would be difficult to find another tech book that had such a high ratio of information to pages; every page is packed full of useful information, ready for immediate application.
Already very excited about the prospects of using Rails as a framework, I still felt inadequate in my understanding of the framework and how it worked under the hood. Everything in Rails to me seemed like magic and it was insufficient for me to know that “has_many” established as one-to-many relationship with another model - I had to know why this was possible. This lead me to pick up the Programming Ruby pickaxe book which is an essential resource for really understanding the Ruby language.
I still am a strong believer in the Ruby language itself. The Rails framework is excellent, but ultimately what allows Rails to be so well-constructed is the extremely dynamic nature of the Ruby language. Engineering software components in Ruby is extremely enjoyable. Sometimes I think that Rails developers put too much emphasis on the Rails side and not enough on the Ruby side. I find that such emphasis also leads a lot of newcomers to Rails with an insufficient understanding of the Ruby language to dismiss the framework for this or that reason. Ultimately a complete and thorough understanding of the Ruby language is essential for appreciating many capabilities of using Rails as a framework for sufficiently large applications.
After these two books which have changed my life, I began reading other Rails/Ruby books to acquire more knowledge and gain better insight into the techniques used my professional Rails developers. Rails blogs were also an essential resource.
The rest, they say, is history! I’ve been using Ruby on Rails ever since, from small to large projects (such as Timothy Hughes Rare & Early Newspapers, which I’ll discuss in the future with this blog), and i’m learning something new every day. Working on the larger projects has really pushed me into new directions with Rails and helped me to establish a much better picture of the tools, plugins, and resources available to me when building software.
And so it is my goal with Rails Garden to document some of the tools and techniques I use in my professional use of Ruby on Rails. Enjoy!
Posted in Personal, Rails General | No Comments »