Updates to work with Rails 4.x, hat tip to jheiss and laserlemon