Fixed Rails 4 and older Rails issues