Review of Agile Development with Rails
In a world of extensive free online documentation and numerous tutorials, we might think that programming books are redundant. On some level, that is probably true. It is entirely possible to pick up the basics of a popular framework and/or a language simply by going through online tutorials. But, for a deeper understanding of what’s going on “under the hood”, nothing beats a well-written book on the subject. This is something that easily applies to Agile Development with Rails (4th Edition) by Sam Ruby (no relation to the Ruby language), Dave Thomas, and David Heinemeier Hansson. I started reading this book after completing the Rails-focused web development program at theFirehoseProject with the goal of solidifying what I learned at the bootcamp. There is a number of Rails books out there, and I chose this one because I figured, since one of the authors is the inventor of Rails, he must know a thing or two on this subject. The book did not disappoint.
The first part of the book guides the reader through creating an online store in a tutorial-like format. The book starts out with a chapter on installing Rails. Then there is a chapter on the tasks of wireframing the app and planning out the database. Finally, we start coding the application by creating the model, views, controller, and database migration for products that will be sold in the store. This is done automatically by generating a scaffold. This is different from what I was taught by theFirehoseProject teachers, who direct students to generate all of these components manually. While the scaffolding method is faster, and it does a great job of showing the “convention over configuration” power of Rails, I don’t think its as useful for learning the relationship between the MVC components as generating them manually. But that’s just an opinion.
Subsequent chapters go through migrating and modifying database tables, validation, unit and integration testing, and front-end layout. This is done as a series of iterations, where the application is built in stages, with each iteration adding a layer of sophistication to the app. I found the explanations to be throurough and clear. Topics that are often confusing to Rails newcomers, such as the naming convention and the HTTP verbs, are explained in seperate sections. There are, however, places where a person who is not already familiar with Rails would probably be lost. For example, the processing of an HTTP request by MVC components is not well explained until the second part of the book. I thought an earlier discussion of MVC would’ve been better. Another confusing spot was where a shopping cart, which was until then updated by reloading the page, was converted to be updated with an Ajax call. This was done by adding “remote:true” to the cart controller and then updating the cart by adding a format.js call in the controller. This was supposed to make the cart updates much quicker by eliminating the need to reload the whole page. The JavaScript and JSON needed to implement this were introduced with a very minimal explanation of how they work.
The detailed workings of the MVC model are described in the second part of the book, which I found to be much more useful than the first. This part helped me clarify details of how an HTTP request is processed by the controller, gave me a much better idea of how finder methods work, the principles of REST, and the workings of the different Rails modules (ActiveRecord, Action Controller, Action Dispatch, Action View). Overall, this book is great for deepening your knowledge of Rails when you already have some basic experience with it and with JQuery/JavaScript. I’ll definitely be coming back to the book more than once.
Let me know what you think of this article on twitter @YuryVoloshin or leave a comment below!