Fixed everything to work with rails 4