Convert activrecord usage to rails 4