updated code to rails 4.1