Fixed compatibility issues with Rails 4