updating code to rails4.1