Fix errors related to Rails 4 upgrade