Converted to rails 4