Fix rails4.1 AR query failure