I had expected this topic to be long, complicated and extremely difficult, but I was pleasantly surprised to learn how dead simple it was to accomplish using tools already built into ActiveAdmin, and more specifically, MetaSearch.
Here’s the scenario: My application contains a model which has attributes for both the start and end of a range. Specifically, a Production has both
end_date columns which together define the span of time over which that production occurs. I wanted a way to search for productions in a time period, but I wanted to see any productions where the range of dates for the production fell within the query window I specified.
Let me give a better example. I have a production that begins on Dec. 1st and runs through Dec. 5th. That range, 12/1 – 12/5 is the production window. I want to query for any productions occurring between Dec. 2nd and Dec. 4th. So the query window is 12/2 – 12/4. The query window is more narrow than the production window, and so simple filtering on
end_date won’t work.