Full Disclosure: I received a free review copy of Learn Ruby on Rails for this review. While that is cool and flattering, I will do my best to remain impartial. I always try to be honest and fair with my reviews, thinking about who would find each book most useful and whether the books are clear, understandable, and engaging. That should remain the same in this case.
To find something to pair up with this book for beginners, I went in the other direction and picked a much more advanced Rails book with Crafting Rails 4 Applications. This book goes deep into the guts of Rails, explaining code samples directly from the source code and showing how to create plug-ins, engines, and rack applications. It should offer a stark contrast to Learn Ruby on Rails and bring out the strengths and weaknesses of both books, so let's take a look at them.
VS. |
Learn Ruby on Rails
Unlike most other software development books, Learn Ruby on Rails is part of an online subscription available at railsapps.github.io. If you subscribe, you get access to two books, the other one being Rails and Bootstrap, and a number of tutorials and guides. Starter apps and an app generator called Rails Composer are also available at GitHub. I didn't look into any of this extra stuff since I already have quite a few starter apps now from the various tutorials I've gone through. If you're curious, I encourage you to check them out for yourself.
I would place Learn Ruby on Rails as easier than either of the other two tutorials I went through: Agile Web Development With Rails 4 and Ruby on Rails Tutorial. Kehoe gives the reader a very gentle introduction to Rails with this tutorial, and keeps the book as short as he can by referring to online articles for installation instructions of Rails and other necessary tools and for more in-depth explanations of various topics.
He also limits the tutorial to the controller and view sections of Rails and leaves out the use of databases entirely. For an introductory tutorial like this, I think it was the right decision. You can still make a decent Rails application without a database, and beginners can focus on understanding the view and controller side of a web application.
I had a somewhat difficult time evaluating this book as an introductory text because I had already read two books on Rails, and essentially nothing was new to me. I can't know for sure how the book would work for someone who had no previous exposure to Rails, but Kehoe certainly did a good job explaining the fundamental areas of development with Rails in a clear, direct way. He started off with an overview and introduction to web development, gave a rundown of available resources, presented agile development processes, and went through how to get up and running with Ruby, Rails, rvm, gems, and Git.
Once the environment was set up and the stage was set, he presented a series of exercises that built up a simple web application with home, about, and contact pages, a couple of forms with validation, and the capability of sending email. Nothing too fancy, but it gives the reader a firm foundation to build on.
Sometimes things were redundant, and chapters would overlap, explaining similar material. As an example, the Git commit and push commands were explained multiple times with increasing detail each time. First, Git was described in a fair amount of detail in its own chapter where it was mentioned that the command git push origin master could be shortened to git push after the first use.
Then, at the end of the next chapter the git push shortcut was brought up again in more detail. Some issues that may have come up when using the shortened command were addressed here, but would have probably been more useful when the shortcut was introduced. I'm not sure why these explanations were split into separate chapters. Maybe it's easier for beginners to pick up more advanced features if they are introduced gradually, but I thought it was a little weird.
There were two things that I really liked about this book. First, Kehoe explores the Rails framework through experimentation, which is a great learning tool. He encourages playing around with the code, and iterates through a number of ways to accomplish what's being implemented. It's incredibly valuable for programmers to get comfortable experimenting with code, learning for themselves what works and what doesn't, and gaining the confidence that the answer is there to be discovered by those that are persistent. Learn Ruby on Rails does a good job developing those skills.
Second, Kehoe forgoes the generators and scaffolding, and instead has the reader create every file from scratch. This teaching method reminded me particularly of Charles Petzold's Programming Windows series of books where he refuses to use Visual Studio's code generation features to write Windows applications. The idea is that the beginning programmer is going to learn much more by writing all the code themselves and understanding what's actually going on. Progress may be slower initially, but the foundation will be much stronger for building on later. I completely agree with that approach, and it was nice to see it in Learn Ruby on Rails.
Having Rails presented this way actually cleared up some foggy ideas and misconceptions I had about the view and controller interactions. It was very helpful, and for that alone I would recommend this book. It's fairly short and easy to work through, making it a good introductory tutorial before you move on to the more advanced ones.
Crafting Rails 4 Applications
At the other end of the learning spectrum lies Crafting Rails 4 Applications. This is a book firmly directed towards intermediate to advanced Rails developers. It assumes you have a working Rails environment and you know what to do with it. José Valim dispenses with any and all introductory material, and after a short preface, he jumps straight into the first Rails plug-in - a custom view renderer for generating PDFs from embedded Ruby templates.
Code examples note which file the code should be added to, but do not show the context around the code, so you have to know where to add it yourself. Basic hand-holding is kept to a minimum so time can be spent going through the plug-ins and Rails source code while keeping the book short. There wasn't even an explanation of how to wrap a plug-in up as a gem and use it in other Rails apps. Luckily, a Step-by-Step Guide to Building Your First Ruby Gem showed up on Hacker News while I was in the middle of this book, so the solution to that problem came right to me. Talk about serendipity.
The setup of the book worked pretty well, in spite of the lack of guidance for anything not directly related to building the plug-ins. For the target audience, this format was probably appropriate, and I actually got a kick out of overcoming some of the challenges I would run into as I was implementing each of the eight plug-ins. I probably made it harder on myself by doing everything in Windows 7, (I know, I know, but I don't have the money to get a MacBook, and I haven't had the time to set up Ubuntu) and things got especially hairy when I needed to install things like OpenSSL, MongoDB, and Redis to complete the later chapters.
I got everything working in the end, and I was even pleasantly surprised that everything I needed was actually available for Windows 7, if I was willing to dig a little. It would be nice to have something like rvm, though. That's still missing as far as I can tell.
Anyway, back to the book. These are advanced topics that Valim covers. He explains how to hook into Rails to add features and extend functionality in the rendering engine, the controllers, the HTTP responder, and the database interface. It was extremely cool to implement plug-ins that could fetch view templates from a database instead of the filesystem, send multipart emails generated from Markdown templates, stream events to clients for continuous updates to web apps, and monitor website metrics with an attached MongoDB database.
Some of this stuff is over my head at this point, but when I get deeper into Rails development, I'll know where to look to find answers to questions I have about Rails internals. Even though I didn't understand everything, going through the examples was a blast, and I learned a ton of stuff about how Rails works under the hood. If you're looking for a book to take your Rails development to the next level, Crafting Rails 4 Applications will help get you there.
The Big Picture
Now that I've read four Rails books, what would I recommend? Well, of the two books in this review, the choice is easy. If you're an absolute beginner with Rails, then Learn Ruby on Rails would be the book for you. If you already have a few Rails apps under your belt, and you want to see how flexible and extensible Rails really is, then you should take a look at Crafting Rails 4 Applications. To bridge the gap between the two, either Agile Web Development with Rails 4 or Ruby on Rails Tutorial would work perfectly, giving you a full path from beginner to advanced Ruby on Rails developer.
Of course, you'll need to actually write a few non-trivial Rails apps before you can claim to have finished this learning path, and Crafting Rails 4 Applications will make much more sense after you do. Have some fun with it, and no matter what level you're at with your Rails knowledge, one of these books will help you reach the next level.
No comments:
Post a Comment