As a fellow AR lover the only things that consistently bug me are when it does things like:
- .count on a collection calls SQL every time, but there is also a .count method for arrays - which means you need to remember to use .length if you just want to count the objects loaded into memory
- ‘build’ methods for an association usually only initialize a record in memory, but with has_one associations it deletes any record that already exists
So basically when it’s not clear about the fact that it’s doing database things.
There's a .size that works for pretty much everything: if the relation isn't loaded then it will do select count(*), but for arrays and loaded associations it does length of an array
- .count on a collection calls SQL every time, but there is also a .count method for arrays - which means you need to remember to use .length if you just want to count the objects loaded into memory
- ‘build’ methods for an association usually only initialize a record in memory, but with has_one associations it deletes any record that already exists
So basically when it’s not clear about the fact that it’s doing database things.