Favorite new tool: named_scope
Update: I’ve been using named_scope for a bit longer now and totally don’t agree with my former self about naming conventions when creating named_scopes. I now do what comes natural. Love, me.
I’ve been using the new-ish Rails feature named_scope for a couple days now, and I love it. The expressiveness was something I really missed jumping from OpenACS, a “framework” where you’re encouraged to write powerful queries in raw SQL. So you get the best of both worlds: modular business logic and (relatively) powerful queries. I wish Rails had more features to enable INNER JOINs using finders in a way that still allows the pre-fetching of associated objects, but that’s another matter entirely. Some observations, though: