fix bugs for turning to rails4