Today I was creating a model method which would return some associated objects. It wasn’t hugely complex but I basically needed to match an sql string which looked something like this:
After reading some arel documentation, I came up this:
1 2 3
If this is a bit too fiddly for you then there are some nice gems that do this for you, such as Squeel.