The interaction between ActiveRecord and the database is very simple when working with a single record – it’s always pretty clear when the database is going to be changed. What about when you’re working with multiple records and associations? I did some experiments way back at the start of the Hobo project, but recently I wanted to check if anything had changed.
So I threw together some simple experiments, and turned on logging in the console. It’s a bit rough and certainly not exhaustive, but I formatted it in markdown out of habit and then though hey, I should post this, so here it is.
Is this stuff documented somewhere? I never found it if it is. I wonder if most Rails devs know about all this already.
This is all in Rail 2.0.2 BTW.
This is the first post in a new category I’ve added to the blog: “Ruby Skills”. It’s a place for me to share Ruby tricks and tips I’ve picked up along the way. Sometimes, as with this post, I’ll post about the Ruby extensions in HoboSupport. Now that HoboSupport is available as a gem, you can easily use these tricks in any Ruby project.
Find what you're looking for quickly by using our keyword search. Can't find it? Try our links below.