Make it work with rails 4

Have been tested with rails 4 and rails 3 applications.