Friday, December 10, 2010

Book Review: Jose Valim's Crafting Rails Applications

Have you already read this?

The following excerpt  by Jose Valim at the end of the book nicely summarizes it:
Finally, you understand Rails better. You can explore other areas of the source code, study other Action Controller and Active Models modules, check other generators implementations or read the source of Railties, Engines and Applications with detail! - Jose Valim
For the impatient readers, this is the best in-depth Ruby on Rails related book I have ever read and you should read this (only 172 pages). Buy the book here. But wait, you could get 40% discount and get the book for $13. I will tell you how, continue reading!
This book literally opens up the Ruby on Rails framework for the readers. So, now I am crystal clear about Metal, Rack, ActiveModel, Rendering, Templating, Migrations, Gems, Engines and so many core concepts. If you are like me, you have cloned the Ruby on Rails code and took a peek into the code to understand, patch some code or just to learn some hidden treasures of Ruby, but had tough time getting hold of the big picture. Well, this book will show you some highways and also some other useful alleys - you can find the rest by yourself!
This book embraces Test Driven Design, so all code examples, and hell yes there's a lot of them, are test driven. So, its unit test, functional test and integration test that drives the show. The topics cover customization of key Ruby on Rails components such as: models, controllers, views, mailers, generators and rack integrations. But the examples are really good as it shows:

  • Responding to pdf requests so that the server responds with on-the-fly PDF responses
  • Using Markdown templates for producing HTML and Text multipart emails from a single source template
  • Rendering views that are stored in a database to work as a simple CMS
  • Publishing and subscribing to Rails internal event such as SQL queries
  • Creating a simple rack application
  • Creating a Rails Engine
  • Creating custom responders so that you can DRY up your controllers that use exactly same lines for respond_to do |format|...
  • I18n translations using Redis key-value store and caching
  • Combining Sinatra with Rails in a single Rails app
To ease the process of trying out the DIY code, Jose Valim created an excellent gem called enginex. This gem gives you an incubator to try out the example code while building your own gem and using it from an embedded dummy application, writing tests and even browsing the app. The whole experience of trying out the code is awesome. Before this, I have never read a book that shipped with a gem just so that the readers could easily use the source code. Awesome idea and even better execution.
While explaining the inner workings of Ruby on Rails framework the book also discussed about a few useful gems:
  1. devise - authentication gem.
  2. enginex - produces incubator for gem development and makes it a breeze.
  3. capybara - drives integrations tests and also works with browsers through selenium etc.
  4. rdiscount - Discount is an implementation of John Gruber's Markdown markup language in C
  5. responders - DRY up your Ruby on Rails application with a number of handy responders.
  6. redis - an easy to use Key Value store.
  7. prawn - Ruby PDF library.
This book also shows a number of cool tricks. Its overall a fun read. I would say, the final version will be  more eye-soothing, but don't wait for that. Grab your ebook now and you will get the updates as they come!
I would like the book more if Jose Valim could reorganize some of the content. For an example, the text about Generators appear in different places. I think it would be easier to follow if it was in a separate chapter. The same applies for Engine.
I have another observation: the book is written for pro developers with substantial Ruby/Rails application. But I think the topics discussed here could also be equally useful to beginners. The later can be achieved by going a bit slow about some of the topics. Jose Valim, can you add little explanations at places for beginners?
The bottom line is, buy this book and read. To receive 40% discount, sign up at http://pragprog.com and refer to a friend and ask her to complete signup. You both get 40% discount. To claim, go to your account and you will find this as soon as your friend completes the signup.
Thank you!
--
This review is not sponsored and contains my opinion only.