Added compatibility with Rails4