Upgraded to support rails4