This Week in Rails: Active Support deprecations and more!

Posted by imtayadeway, November 18, 2016 @ 12:00 am in News

Hello everyone!

Tim here bringing you all the latest from This Week in Rails…..

This Week’s Rails Contributors

This week 29 lovely people contributed to Rails, including an incredible 9 for the time! Why not put yourself in the next installment of This Week in Rails by tackling one of the open issues out there?

Improved

Remove Active Support deprecations

In preparation for the 5.1 release, methods marked as deprecated in 5.0 are being removed. If you’ve been seeing any of these warnings, you need to get on ‘em now! Notably, this PR waves goodbye to ‘alias_method_chain’ , which was made obsolete by Ruby 2.0+’s ‘Module#prepend’

Fixed

Support AC::Parameters for PG HStore

As of Rails 5, Active Record determines that a value needs to be serialized if it is a ‘Hash’ object. If passed an ‘ActionController::Parameters’ object instead (which no longer inherits from ‘Hash’ ), serialization would break. This change restores the original behavior.

Fix JSON encoding of “Infinity” and “NaN” values

If ‘as_json’ returns “Infinity” or “NaN” for any value, it causes ‘JSON.generate’ to 💥 because these values are not allowed in JSON. Instead of being treated as primitives, ‘as_json’ is called on these values recursively, so that they are properly serialized as “null”. Phew!

Fix incorrect output from rails routes when using singular resources

‘rails routes’ was showing some incorrect output if you had singular resources defined. Specifically, routes for the # ‘show’ action would appear under the “edit” helper, which is clearly wrong. Thanks to the rjigging of the order in which they appear in this PR, your routes should now be correct!

Correctly count new records when calling uniq on associations

If ‘CollectionProxy’ has more than one new record, a call to ‘uniq’ would yield the wrong result. This was because this method was aliased to ‘distinct’ , which is really a different concept. The original behavior was restored thanks to this reversion.

Wrapping up

That’s it from This Week in Rails! There were many other great contributions, too numerous to list here, but feel free to check them out!

Until next week!