Home rails 4.2 upgrade broke json rendering
Reply: 0

rails 4.2 upgrade broke json rendering

noobler
1#
noobler Published in 2017-12-07 19:21:35Z

I tried upgrading my rails app from rails 4.1.0 => 4.2.7 but found that it broke my JSON views. In particular, ActiveRecord objects no longer render correctly.

For instance: Model.first.to_json in rails console now produces "#\u003cModel:0x007f9208c904e0\u003e", rather than valid JSON as before. Model.first.as_json works correctly, but for some reason, it seems to_json is calling to_s instead.

I tried overriding the ActiveSupport encoder but it didn't help, and am pretty stumped. Any ideas?

(UPDATE: I also noticed Time.now.utc.to_json changed from 2017-12-07T19:38:47Z => 2017-12-07 19:37:55 UTC, the latter being == time.as_json and the former == time.to_s)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.294941 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO