This is not a programming guide. Yes, there is code, but this digital shortcut is not about coding. Rather, this is really a short about design, about philosophy, and about appreciating beauty. This short looks at the way in which the grace of Ruby informs the design of Rails.
This is a surprisingly underappreciated concept. Of course, many people have already written about what they find beautiful in Railsaspects of style we will explore furtherbut what the newcomer to Rails might miss is that Rails's design directly reflects Ruby's underlying beauty. Although the name Ruby on Rails suggests that the Rails model could be developed on top of other languages (Perl on Rails? Visual Basic on Rails? Cobol on Rails?), such development is impossible without losing some things in the process. Sure, any Rails port or clone can share certain outward similarities (in the way a cheap lemon and a well-designed automobile both have steering wheels and engines and doors and seats), but Rails's success is as much a measure of Ruby's expressive power as it is of Rails's conventions. Sadly, however, this point is usually lost on people coming to Rails from other more limited languages (PHP, Perl, C++, Java, and so on); but then again, it is never really a connection that is stressed.
This digital shortcut is not a guide for learning Rails; you can already find many excellent books on that topic. However, all of them are designed to quickly drive their readers toward proficiency in Rails. They just do not have the luxury of exploring the Ruby foundation of Rails in any depth. Instead, they usually have to treat distinctive Ruby featuresthings such as symbols, blocks, and metaprogrammingin passing (if at all), like quaint towns and scenic overlooks glimpsed briefly from a car hurtling forward on an interstate highway. The problem here is that the beauty of Ruby gets short shrift. Therefore, many people who have come to coding in Ruby from Rails do not really get Ruby as much as they would like. That is where this digital shortcut comes in.
We're taking the scenic route instead. I do not cover a hitlist of topics either quickly or in depth. I do not teach you Ruby or Rails in 10 days or your money back. I assume you already know how Rails works. By extension, I also assume you have some experience with Ruby but do not understand it entirely; that is, your Ruby coding resembles more Ruby-inflected PHP or Ruby-tinged Java, and you want to become more articulate in the Ruby language. This is not an in-depth guide to the Ruby language, however. Instead, I share with you a few examples of code from within the Rails source code (and perhaps a few other places) that I think are beautiful, some of which also conveniently cause confusion and bewilderment to newcomers. The main goal is aesthetic appreciation and philosophical alignment, nothing more. However, I hope this approach affects you in subtler waysimproving your understanding of why Ruby works and how you can become a better programmer in it.