Combining Scopes & Ransack thanks to Virtus & Siphon
There's a common feature request on the [ransack] issue page and that's to integrate your usual ActiveRecord scopes within the search. Indeed ransack is a fantastic tool to quickly setup a form for selecting table rows depending on column values. But it falls a little short when you want more complex, relational searches. So you almost naturally add a scope in your ransack powered search form before you realize it doesn't work and there's no clear way to do it.
Ransack won't take it all
The problem with that attractive and somewhat obvious feature request is [ransack] relies on the typecasting activerecord performs on its attributes, to coerce all the string values of the parameter's hash into their real value. When
params[:user][:age_gt] => "18" barges into your model it knows "18" should be an Integer (because the corresponding DB column says so) and will pursue accordingly.
On the flip side your model has no reason to know what's the ar