- ARCHIVE / IncludeByDefault
- How to fix bugs in software the hard way, or, why open source software is so damn helpful
If nothing else, this week has taught me a few things about bug fixing. As I’ve written about before, my IncludeByDefault plugin (or, more accurately, the project I’m using it for) exposed a bug or two in Rails. Revision 17 is the result of a very messy process trying to chase a bug up and [...]
- IncludeByDefault progress
IncludeByDefault, as mentioned in my last post, hit some snags with ActiveRecord generating duplicate table aliases when doing cascaded includes, e.g.
Tag.find(8).posts.find(:all, :include => :tags)
So, I set out to work around it, only to run into further problems. I went with option C: let find operations get all the way to the database, and then catch [...] - Including in circles
Not long had I been using my new plugin when I discovered it made this happen when trying to eager-load on a many-to-many association:
SELECT DISTINCT news_stories.id
FROM news_stories
LEFT OUTER JOIN countries_news_stories
ON countries_news_stories.news_id = news_stories.id
LEFT OUTER JOIN countries
ON countries.id = countries_news_stories.country_id
INNER JOIN countries_news_stories
ON news_stories.id = [...] - New Rails plugin: IncludeByDefault
It’s true, I’m a plugin writing machine. Seriously though, this one’s tiny. I took all of five minutes to write. What it does is, it lets you specify a default value for the :include option on ActiveRecord::Base.find, so you can automate eager loading of associations. I’ll use an example I’m comfortable with:
class BlogEntry [...]