Fix Rails 4.2 deprecation warnings and behavior changes