Hello everyone, this is Godfrey reporting from Portland, OR. This week has been a mix bag for me – on one hand, Portland had a pretty miserable week due to the storm; on the other hand, a lot of exciting changes landed in Rails. Does that make things even? I guess we’ll go through the changes and you can decide for yourself!
Last week, we mentioned that Rails 5.1 is gaining a –yarn option. This option is now promoted to be the default: every new Rails app will be set up to use yarn out-of-the-box. It’s also worth noting that yarn packages are now installed into the vendor/node_modules directory.
Friends don’t let friends use INT as a primary key – your app might hit Webscale™ before you know it, resulting in much sadness when your primary key column overflows. To help put you on the right path, Rails 5.1 will default to using BIGINTs for primary key columns in MySQL and PostgreSQL.
As of this pull request, if your model failed to save due to a NOT NULL constraint, Rails will raise a NotNullViolation error (instead of a generic StatementInvalid error) so you could rescue the error and handle it appropriately.
This patch fixes an issue where templates are needlessly recompiled between integration test, resulting in a significant speedup.
Previously, certain race conditions could cause your after_commit callbacks to fire more often than expected. This patch attempts to more accurately track the work that actually happened in the database to ensure your hooks are triggered only when appropriate.
Have you tried using variables named block in your templates? If you did, you might have seen a pretty strange error from Rails. Not anymore! With this patch, you would be able to do that without issues.
A change in Ruby 2.3.0unexpectedly changed the behavior of Active Support’s Class#subclasses and Class#descendants methods to include singleton classes. This patch restores the previous behavior and made things consistent across different versions of Ruby (again).
That’s it from This Week in Rails! There were many other great contributions, so please feel free to check them out yourself!
Until next week!