The last post covered some of the basics of aggregate commands, but left out a section explaining the more perilous aggregates of associations and more advanced querying against them.
Here are a few questions to get you thinking before we start. Given a model Foo which
(key, value, foo_id):
- How do we find the count of tags for every Foo?
- How do we find a Foo with multiple matching tags? (name: ‘David Tennant’ AND color: ‘Blue’)
Suddenly ActiveRecord becomes very annoyingly complicated to use, but not to fear! We can still use SQL for all of this.