This post originated from an RSS feed registered with Ruby Buzz
by David Heinemeier Hansson.
Original Post: Getting Things Done with Active Record
Feed Title: Riding Rails
Feed URL: http://sedoparking.com/search/registrar.php?domain=®istrar=sedopark
Feed Description: The knowledge diff for all things Rails
Mike Clark has a great article on how to dig deeper into Active Record by using acts_as_nested_set and find_by_sql. On the notion of using SQL in an OO model, he writes:
Some may think this breaks object purity. I think it’s just productive. After all, I know there’s a database under there, and SQL is incredibly powerful for querying relational data. Most of the time I’d rather not write SQL because I’m doing CRUD operations. In those cases, Active Record intervenes to boost my productivity. And when SQL is the best tool for the job, Active Record gets out of the way to let me be most productive.
I couldn’t agree more. SQL is not bad at all. Once you take out the repetition for the simple cases, you’re left with a very powerful query language for the hard cases.