Tag Archives: activerecord
Rails Gotcha: ActiveRecord Caches Associated Records by Default
ActiveRecord will cache the results of association method calls by default, unless you tell it not to. (This applies to Rails 2.3.2 and perhaps earlier versions.) From the documentation: project.milestones # fetches milestones from the database project.milestones.size # uses the … Continue reading
Don’t try to be smarter than ActiveRecord
When you’re writing conditions for a finder in ActiveRecord, and you want to use an array of values for a sql in() statement, you might think to help ActiveRecord out and comma-separate the array values like this: type_ids = [1, … Continue reading