Fix Rails AR query conditions