riot.projects

riot.projects is the tumblelog of Aubrey Holland. You can find me on twitter at @riotpolice

record_filter adds column comparisons across tables

I just released version 0.9.14 of record_filter with a spiffy new feature that allows you to compare columns across tables instead of simply comparing columns against your data. Let’s say you have a Blog class that has_many Posts and you want to only get the articles that were created since the last time their publication was updated. Now you can do this:

Blog.filter do
  having(:posts)
  with(:updated_at).lt(:posts => :created_at)
end
This came in handy for the world’s nastiest query that I’m working on, and I hope it will help others as well.

Comments (View)
blog comments powered by Disqus