RSS
23 Oct 2007

Be an Expert of Ruby on Rails’ Active Record!

Author: ceefour | Filed under: Books, Cool, Enterprise, News, Opinions, Praises, Rails, Reviews, Ruby, Tips

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Any Ruby on Rails programmer would have touched Active Record, probably in a very early phase. Active Record deals with everything that’s related to the database of your Ruby on Rails applications, and in many ways a bit more.

 Be an Expert of Ruby on Rails’ Active Record!

Apress recently launched Pro Active Record: Databases with Ruby on Rails, which I can honestly say, is the most exhaustive, if not the only, book about Active Record I’ve ever known to date.

The book starts with a little bit of a “wow” factor, especially true if you’re new to Ruby on Rails: demonstrating the ease of use of Active Record itself. No configuration needed! Seriously, that’s not the claim of the book but it’s fact of Active Record: all you need is your database credentials and name of the table you want to work with. Everything else is almost magical.

The next sections deal with installing and configuring Active Record. I have to say sometimes (based on my own experiences) it’s not that trivial, especially on Windows. The book guides you through installing drivers/adapters for common and less popular DBMSes. OK, let’s name them: DB2, Firebird, FrontBase, MySQL, OpenBase, Oracle, PostgreSQL, SQLite, Microsoft SQL Server, Sybase, they’re all covered! I was wondering if I can connect to ODBC?

The second chapter deals with the “simple” things, namely, how to do SELECT, UPDATE, DELETE, INSERT, or what you cool guys usually call “CRUD”, the Active Record-way. This information is usually taken for granted, but it’s explained quite deeply in this book.

The next chapter guides you to design your tables so they work smoothly with Active Record. Although you can use legacy designs just fine with Active Record, your life will be much, much easier if you follow Active Record conventions. This book shows you just how, and in many cases, why.

Chapter 4 shows you how to use core Active Record features, including triggers and validations. If you’re asking that question, then the answer is yes, it’s almost completely overlapping with native but proprietary DBMS functionality such as PL/SQL, DBMS triggers, and constraints. The book doesn’t seem to explain much of this holy war, but I encourage you to ask Google why stored procedures are evil.

Chapter 5 gives you a view of Active Record “bonus features”. I think the chapter title is a misnomer because these features are not just bonus, but one of the greatest strengths of Active Record (compared to other ORM). Things like nested sets, lists, observers, aggregations, and little bit of extending Active Record: these are things that you’ll do, and use, daily — not something you try to avoid. They make your life as a DB integrator easier, not the other way around.

You want to make sure your app works fine, chapter 6 covers unit testing very thoroughly, down to the descriptions of errors (i.e. Active Record Exception objects) you may encounter.

If you already had a previous database, as most of us are, no worries, chapter 7 will guide you how to work with them. This is one of the most useful chapters in this book, because there is less information on the Internet on this topic, but it’s very common that everybody is bound to meet this problem. Come on, who actually learned Active Record before hearing the word DBMS?

The last chapter talks about issues that you’ll encounter in the “real world”, including alternatives and related enhancements to Active Record. What follows is the appendix, which is a really useful quick reference.

The book is really, really good. Full of core information, and related information that aren’t readily available even after asking Mr. Google a hundred times. Despite being written by 3 different developers: Kevin Marshall, Chad Pytel, and Jon Yurek; the entire book is nicely structured and feels cohesive. It will save you lots of time in times of frustration, you can look up the information much quickly here than does a search engine.

Interested already? You can get more information about Pro Active Record book on Amazon, and buy it there too of course. It’s also available on Apress official site.

Personal minor gripe, not a flaw, is there wasn’t a (detachable) cheatsheet. A poster-sized, deluxe exclusive cheatsheet would be a tremendous killer plus to this book. I really think Apress should make this kind of thing mandatory in the future, not only regular Appendixes.

Other resources related to this book:

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

blog comments powered by Disqus