[WIP] Upgrade to rails master/4.2

I was going to send this when I have the complete set of patches required, but I noticed @SamSaffron has started working on it too, so we should probably share notes :smile:
FWIW, I "just" changed the implementation here: https://github.com/chancancode/discourse/commit/a66c3fedf07d7cfba4ca6e72bb2123b2605d5a12

Moving the discussion to https://github.com/rails/rails/issues/17294