Added Rails 4 fixes from jasonbuehler