This is Vipul , happily reporting from a Simmering Summer 😎. Pour yourself a drink 🍹, sit back, relax and enjoy, as we go through these hot off the press changes.
With the new Attributes API, it is now possible to specify a proc as the default values for an attribute, which allows for runtime-generated default values such as attribute :year, :integer, default: -> { Time.now.year }. See also these related changes.
By default, Rails overrides MySQL's sql_mode setting with sql_mode=STRICT_ALL_TABLES to prevent silent data loss. While this is helpful, it has the unfortunate side-effect of overriding any user customizations.
If you prefer to manage this yourself, you can now specify strict: :defaultin your connection's config and Rails will leave your sql_mode alone. (STRICT_ALL_TABLES is still highly recommended though!)
If you are using render nothing: true, you should start replacing it with head :ok, which does the same thing and is more semantic. This option will go away permanently in Rails 5.1.
The superficial similarity between Relation#uniq and Array#uniq has been a source of confusion, which led to the addition of Relation#distinct which better communicates what is happening under the hood.
The recent discussion on #20198 put the final nail in the coffin for Relation#uniq and its friends, #uniq! and #uniq_value. These methods are deprecated and scheduled for removal in Rails 5.1, so you might want to start using #distinct, #distinct! and #distinct_value soon.
That's a wrap
That's all for This week in Rails. As always, there are many more changes than we have room to cover here, but feel free to check them out yourself!
P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don't hesitate to contact Godfrey – there're a lot of ways you could help make this newsletter more awesome!