This Week in Rails: HTTP/2 Early hints, friendly error message and more!

Hi there! It’s Prathamesh from Pune, enjoying rain 🌧, sipping ☕️ coffee  and bringing you latest news from the Rails world. Let’s get started!

This Week’s Contributors

13 people contributed to Rails the past week! If you’d like to join them, why not check out the list of open issues?

HTTP2 early hints support for Rails

Early Hints is a new HTTP status code that allows your application to send links to assets that you would like to load early. The spec is still in draft but Rails is ready to support it along with Puma. Check this blog post to know more about this feature.

Friendly error message when unsubscribing from non-existent Action Cable subscription

If for some reason the frontend code tries to unsubscribe from a non existing Action Cable subscription, then a friendly error message will be displayed:

Unable to find subscription with identifier: {“channel”:”SomeChannel”}.

Earlier, it used to show:

NoMethodError - undefined method `unsubscribe_from_channel’ for nil:NilClass

Feel free to check out the full list of changes.

Thanks to the 13 people contributed to Rails last week. If you’d like to join them, check out the list of open issues. Until next week 👋 

Rails 4.2.10 released

Hi everyone,

I am happy to announce that Rails 4.2.10 final has been released!

As noted in the rc1 post, Rails 4.2 is no longer supported except for severe security patches, but the last release introduced a couple regressions that warranted a release. Unless more regressions are found this will likely be the last bug fix release for Rails 4.2. :champagne:

CHANGES since 4.2.9

The following gems had changes since 4.2.9. Changes are listed below, or you can read the CHANGELOG’s on GitHub:

Fix regression in behavior of normalize_path.

In Rails 5 there was a change to ensure the encoding of the original string in a path was maintained. This was incorrectly backported to Rails 4.2 which caused a regression.

Relation#joins is no longer affected by the target model’s current_scope, with the exception of unscoped. Fixes #29338.

The remaining gems (Action Mailer, Action View, Active Job, Active Model, Active Support, and Railties) had no changes.

Full list of changes

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-256 hashes.

Here are the checksums for 4.2.10:

$ shasum -a 256 *-4.2.10.gem
a93cedc87c05e4360dee32777872a9b851295e96d8a32b96ebc13e7c95967ec7  actionmailer-4.2.10.gem
fd6625bcb84dbfb48d7e7f6ab7d2b88ede925a455db02fbaec5047d57a7eca50  actionpack-4.2.10.gem
1bae4a0385ba7384ed2ae4eddff80076f0c6b21cfc9d60cf0767723feb153dcb  actionview-4.2.10.gem
e80776a73ba5cc32fefb372f11db289153b954c91db378ad689ad1896f515a82  activejob-4.2.10.gem
3b513adc4f7483da117d25ac6505cc46794b4eb457b28597014975a97a929b30  activemodel-4.2.10.gem
3218dbfa6f46df8e820577d56a21a3c9b9bb3f32410803a4357200b756594c5a  activerecord-4.2.10.gem
275b14e515eb8c924bafa734417ec053a57f177ae9d3369f753d6f4437922268  activesupport-4.2.10.gem
141067e1dd4ec59d7a49e54936b68d8e44d8616515625dcf0387405a276d6b97  rails-4.2.10.gem
3709315c522a2729bb7dcf97c05acc2d47b61521cac450ee03143321b1abde6a  railties-4.2.10.gem

As always, huge thanks to the many contributors who helped with this release.

This Week in Rails: New credentials configuration, bugfixes and more!

Hi there! It’s Greg, bringing you a double-edition of This Week in Rails!

This Week’s Contributors

28 people contributed to Rails the past two weeks! If you’d like to join them, why not check out the list of open issues?

Rails 4.2.10.rc1 released

Although Rails 4.2 is not officially supported anymore, this release fixes some regressions introduced by the previous one. If no new regressions found, the final should be released mid next week.

Introducing config/credentials.yml.enc

Rails 5.2 will introduce a new credentials configuration file to store encrypted data like API keys and the secret key base. This will eventually replace Rails.application.secrets and the encrypted secrets introduced in Rails 5.1.

Add with_attached_* scope

To avoid N+1 queries when using Active Storage, this PR added with_attached_* scope to the has_one_attached macro.

ActiveRecord::Associations::Preloader memoization improvement

With this change the association pre-loader became slightly faster.

Implement change_table_comment and change_column_comment for MySQL

change_table_comment and change_column_comment are implemented for the MySQL adapter as well now.

Fix Active Storage direct upload in Firefox

Direct upload in Firefox was not working because it can’t handle click events on input[type=submit], but this PR fixed the problem.

Capybara puma server configuration fix

This PR fixes an issue when the config/puma.rb configuration is loaded for system tests.

That’s it for this now! As always, there isn’t enough time to cover every change if you’d like check out the full list of changes yourself.

Rails 4.2.10.rc1 released

Hi everyone,

I am happy to announce that Rails 4.2.10.rc1 has been released!

Per our release policy Rails 4.2 is no longer supported except for severe security fixes, but the last release introduced some regressions that warranted a release.

If no new regressions are found, expect the final release on Wednesday, September 27, 2017. If you find a regression, please open an issue on GitHub and mention me (@eileencodes) on it.

CHANGES since 4.2.9

The following gems had changes since 4.2.9. You can read about the specific changes in the changelogs on GitHub:

The remaining gems (Action Mailer, Action View, Active Job, Active Model, Active Support, and Railties) had no changes.

Full list of changes

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-256 hashes.

Here are the checksums for 4.2.10.rc1:

$ shasum -a 256 *-4.2.10.rc1.gem
91f279396cd0757784445294a0422c37113a6d49c856ed1b6ce60cd2d6cd4c57  actionmailer-4.2.10.rc1.gem
2f582b5c3b42dea2a877af76812168ad721b583f501c748c32699686d8996c6e  actionpack-4.2.10.rc1.gem
1f587908650b6e96a500de3ccbeb229e8ffe1b8a06bbadc930acad762dd70503  actionview-4.2.10.rc1.gem
b68b1e2475e6cb118a66c9b1daa172965b634b311e81e6ec686f819f0c71c1c4  activejob-4.2.10.rc1.gem
18507309ed0f00f5a6ffc09da1df5076f016f516ce8e7afe2b4138353ca7c915  activemodel-4.2.10.rc1.gem
53a094625fe76d353d95cfd5cf0d989e5f0f18572cded546e3942e2647fdac5e  activerecord-4.2.10.rc1.gem
e4bb02e67d57e9c52fbe0f90b367eb653f4906351b470ce60b34556bb5710b96  activesupport-4.2.10.rc1.gem
9e43e2cda17c4d68b65eff9ef4df6c62c87a0f5779a612fd3dc06e80f0182c7c  rails-4.2.10.rc1.gem
360a5c67a78c5fffaa27c6caa6ae4663d49ab675507ed61f95d2f51869b671b4  railties-4.2.10.rc1.gem

As always, huge thanks to the many contributors who helped with this release.

Rails 5.1.4 and 5.0.6 released

Hi everyone,

I am happy to announce that Rails 5.0.6 and 5.1.4 have been released.

CHANGES since 5.0.5

To view the changes for each gem, please read the changelogs on GitHub:

Full listing

To see the full list of changes, check out all the commits on GitHub.

CHANGES since 5.1.3

To view the changes for each gem, please read the changelogs on GitHub:

Full listing

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-256 hashes.

Here are the checksums for 5.0.6:

$ shasum -a 256 *-5.0.6.gem
8321d86a6bb9ec85b5189093139bbdfb87ad1935166e5c0eac422068a2a6e515  actioncable-5.0.6.gem
bb1113dd020f310fc7948bd13766eeab6cf975a0e1322c8a10cd12adbcacea4f  actionmailer-5.0.6.gem
1866fbaafcba1a6f23ea075f0c7add8980f99d2f2ddc37032d4b62033b39bf8d  actionpack-5.0.6.gem
6d256fba84733b0dc8a22de7264ceb77ef2ddeae2913632300c76182ecd6d36d  actionview-5.0.6.gem
78190e9f3ab0185734a123907cfa1b847e96d4b1303dcb8304e8bb0d26e64bcd  activejob-5.0.6.gem
f8f7d7e18df7fef01c1c299619c60e9b2becafc141450c3482b95ea85b6eebd6  activemodel-5.0.6.gem
f0065962596bb8d483e0e308bca2611357e4844e86a9d53a99bbee826aa85a19  activerecord-5.0.6.gem
e6f98107623edb19cc25ca2aab134b857f291529ab37a1d00b47560d30a6053d  activesupport-5.0.6.gem
a86663f8d0d4dd0cb07272394a6d0c7d250be617c6efe77edd2ebc9c9d139746  rails-5.0.6.gem
b05fbd99673637408badc3da8988aa76c9f245d9f0202dc65389e6b619e97772  railties-5.0.6.gem

Here are the checksums for 5.1.4:

$ shasum -a 256 *-5.1.4.gem
47d968f5636aa2ee88cb6306a7cb8b426b2156c93851628a354cae9139d56916  actioncable-5.1.4.gem
5ae798850bd284f803cc006887d6b089692183a8c192393436c519bd6ec598e9  actionmailer-5.1.4.gem
f5d0e747051923f19d932bbc5c274353d026d3b4aaf9504f240161330555e4c6  actionpack-5.1.4.gem
302f398a86337818e6f4225934b136436cab5fdfe2fcd6dd7509b1f595a417c2  actionview-5.1.4.gem
f7814fdf4a7592f7f6774f68c5adec53cbcbf825a61bae91219c730ba1cb6bca  activejob-5.1.4.gem
4008ad8f54e149ddf3a7173aba743bf8b39e4eba517e91ba8704aea739129a63  activemodel-5.1.4.gem
89be7874c962070c47ce52ea1182b9920c40f74f27da6d43670ed976aeb2413e  activerecord-5.1.4.gem
9969d4fdc7e1fad82f02f457b03995baa74928e99f73d035564c9eec7426ee69  activesupport-5.1.4.gem
5cc2192045678789e5e7b289476af8bc0a79210ee6713886200cb303ed6f98b8  rails-5.1.4.gem
e477f332b4810f634b58a33c3accdebcfb9d3ab1f4b7b3ed204269d6b1a28001  railties-5.1.4.gem

As always, huge thanks to the many contributors who helped with this release.

This Week in Rails: engine screenshots, method redefinitions and more!

Oh, hello there! I’m Tim, and if you’re reading this that means you’ve got Rails fever! It’s time for your weekly dose of This Week in Rails….

This Week’s Contributors

This week 21 people contributed to Rails, including 4 for the first time! If you’d like to join them and perhaps get a slot in next week’s edition, why not check out the list of open issues?

Support multiple version arguments for gems in generators

The gem method can now support multiple version constraints, just like in rubygems!

Make take_failed_screenshot work within engine

This method used to get the tmp directory relative to Rails.root, which in an engine points to the dummy application, where no such directory exists. This was fixed by using the path relative to the current directory instead.

Clarify intentions around method redefinitions

This fixed a race condition in class_attribute, which in redefining an attribute had to remove it first and then redefine it. If another thread was trying to access that attribute in the middle of that, it would raise a NameError. Thankfully no more!

….and that’s a wrap! As always, there is never enough time or space to cover every change this week, but we value each and every one. If you’d like to know more you can check out the full list of changes yourself. See you next time!

Webpacker 3.0: No separate process needed, less config generated

We’ve just made it even easier to use Webpack with Rails with this third major release of Webpacker. The two big changes are that a separate process is no longer needed in development and that the vast majority of the config now lives in the Webpacker npm package, so your config/ directory stays clean and updates are much easier.

We nixed the need for the separate process by allowing Webpacker to compile on-demand in development as well as testing. We’ve done a lot of work to speed up this process, and for lots of apps, the performance will be more than fine. But if you have a huge app, or if you like live reloading or hot module replacements, you can still use the bin/webpacker-dev-server. Webpacker will automatically detect if this process is running and start serving packs from there rather than on-demand. Really slick.

We also dramatically cut down on the amount of config boilerplate that’s generated in the Rails config/ directory. All the standard stuff is now living inside the Webpacker npm module, which makes upgrading so much easier. And you can still overwrite any of the defaults as you please. So it’s a big win all around.

Additionally, we’ve moved all the compilation and clobber logic out of the Rake tasks and into the Webpacker singleton instance itself. This makes it easier to use Webpacker in custom setups, like if you don’t use Yarn or have a different deployment strategy than just assets:precompile.

This follows from a large refactoring of the Webpacker internals. Gone are the many individual singletons, replaced by a single top-level singleton that just aggregates a normal set of classes for configuration, compilation, and so on.

Webpacker 3.0 points to what a Webpack-by-default strategy could look like in Rails 6.0. One where the asset pipeline focuses on static assets, like images, fonts, sounds, and compiled CSS, using SASS and so on, but bows out of the JavaScript compilation game. We still haven’t pinned the final approach, but this is our best current take on how the two could split the work-load of dealing with JavaScript, stylesheets, and other assets in the next big Rails release.

If you haven’t yet given Webpack, ES6-flavored JavaScript, and all the other modern improvements to the client-side development experience a spin, then Webpacker 3.0 is a great place to start. At Basecamp, we’re already using it in production, even though we don’t use any of the big JavaScript client-side frameworks. It works great with the Turbolinks + Action Cable + Vanilla JS approach too.

And if you’re looking to use React, Vue, Angular, or Elm with Rails, Webpacker makes the whole thing so much easier. We still have a bunch of Hello World generators for these four frameworks, so you can get started with development without any manual drudgery of configuration.

This major new release has many contributors, but I want to especially thank Gaurav Tiwari and Javan Makhmali for their big, continued contributions. Enjoy!

Image alt text gone, restart/cache command fixes and more!

Hello everyone!
This is Vipul from Rainy Pune ☔ , cozying up with a ☕, bringing you a recap of the changes  that made it to Rails this week.
If you too want to contribute to Rails, head over to the issues to help us out!

Do not generate default alt text in image tags

Previously Rails auto-generated alt text for an image from the file name if it was not provided with an image_tag. This generation could be distracting and fatiguing for screen reader users if not considered properly.

After this change, if authors leave images without alt text, Rails will not pre fill it anymore, leaving screen readers to prompt authors to fix the issue.

Prevent extra “SET time zone” in configure_connection

Previously Rails would end up setting database connection timezone twice, once if passed via configuration in configure_connection and secondly while setting default timezone.

This change removes setting timezone on database twice if timezone is already passed via configuration variables.

Add TransactionTimeout for MySQL error code 1205

This PR adds TransactionTimeout error to the MySQL adapter, which handles the error:
Lock wait timeout exceeded; try restarting transaction (MySQL error 1205)

Encode Content-Disposition filenames according to RFC 2231 in Active Storage

Before this change, urls for files with non-english names would create issues in Active Storage.

This change fixes encoding Content-Disposition for filenames to RFC 2231, to fix this issue.

For signed/encrypted cookies with ``:expires` like

cookies.signed[:user_name] = { value: "bob", expires: 2.hours }

Rails now embeds the expiry within the written cookie payload. This way Rails isn’t reliant on clients to honor the expiry, but can verify it independently server-side.

Make restart and dev:cache tasks work when customizing pid file path

Previously rails dev:cache failed to restart the Rails server when it was started with a custom pid file path.
With this change, restart no longer fails for a custom pid file and successfully restarts Rails server on dev:cache changes.

Fix can't modify frozen String error in display_image

This change does a quick fix for an error with display_image in System tests, which is used for screenshots, that used to raise an error when trying to modify a frozen string.

Fixes :inverse_of association option not working with eager_loading

Previously calling an eager_load on :inverse_of association failed. This was a regression from Rails 5.1 release. 

This change, fixes the regression.

That’s all for this week! Feel free to check the full list of commits if you are interested. Until next week!

Rails 5.1.4.rc1 and 5.0.6.rc1 released

Hi everyone,

I am happy to announce that Rails 5.0.6.rc1 and 5.1.4.rc1 have been released.

If no regressions are found, expect the final release on Tuesday, August 29, 2017. If you find one, please open an issue on GitHub and mention me (@eileencodes) on it, so that we can fix it before the final release.

CHANGES since 5.0.5

To view the changes for each gem, please read the changelogs on GitHub:

Full listing

To see the full list of changes, check out all the commits on GitHub.

CHANGES since 5.1.3

To view the changes for each gem, please read the changelogs on GitHub:

Full listing

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-256 hashes.

Here are the checksums for 5.0.6.rc1:

$ shasum -a 256 *-5.0.6.rc1.gem
0490ac6c4621756871839ad584f0a0349a72a9ccdeac0f72dafd3539638ba5ef  actioncable-5.0.6.rc1.gem
fc7697724d884307bf2ea307c028902f71f96304b9a882418e6ec94d10202cd9  actionmailer-5.0.6.rc1.gem
b0f1f4479f61ada80b3dbe3e9ccaa0db390119918e5da632dda3c8398e6e4f5f  actionpack-5.0.6.rc1.gem
673d06523edf733163ad668fe3cd64bd1c7fb97244c952241d1e00ee6835101b  actionview-5.0.6.rc1.gem
ac6521d4df459db19fc0f2740d0e0c0a6f3102252c8124ecb25e8d33335d6cf4  activejob-5.0.6.rc1.gem
0824cd58f175a3c825dce9d42d73254d25af25d824ae1c5c3465f12bb0812f72  activemodel-5.0.6.rc1.gem
7972a8a76c711b8fc01ab52d95c4f16a73e9683e4d745a17d61ab91051df856c  activerecord-5.0.6.rc1.gem
40f0c77de7e54b6a3581272ce5b6409ae0c61b5bfad3239db46807d8342ce8a3  activesupport-5.0.6.rc1.gem
7873311d5340bffbabeb33cb9d3ce2c97056bc2bebad3abfcba6f5b38b209075  rails-5.0.6.rc1.gem
3fd4b347f19fb4ff2ec7cee4c9a45aba31d1e287583943269bc9d09bef61ca93  railties-5.0.6.rc1.gem

Here are the checksums for 5.1.4.rc1:

$ shasum -a 256 *-5.1.4.rc1.gem
6ebb05e31a5d46379f638092742aa1543ab3522302a62351de9e5dc746fc7c77  actioncable-5.1.4.rc1.gem
fb3e3743a29a70524c64caa656056f7cf0085998a1438b28325c6e10a6330efd  actionmailer-5.1.4.rc1.gem
c4b39e9b721a4b2eb37be9f18bfbc0a479b61ae4d6b536b1b9f2fc06f83f6ad8  actionpack-5.1.4.rc1.gem
9930cccacbe71085b894ca0410da07625b801c4db1775b655357bd2bf5824ae9  actionview-5.1.4.rc1.gem
e0c7610f4fe20c778e5f9739f80ae4d5d3450bbacff49d24064b0b3b048f9dd6  activejob-5.1.4.rc1.gem
11dae082bd1dfea9541a60501135bef6c32d792407dea57250dc95ba5e415a77  activemodel-5.1.4.rc1.gem
3b058a80c8f14c324dad4c185825a4ce4c4f853af37002bec92e179bef583fcb  activerecord-5.1.4.rc1.gem
c9984249c0200e9c1f462779294e0cec6bb6c8b95421dc01b579a0efa2db6561  activesupport-5.1.4.rc1.gem
c8134e1efcc5f17ac28927a76423146f3a7baf618d97a5d752d09edf4c5eeb7c  rails-5.1.4.rc1.gem
7589a79f6b4a4de73d2d427193eb9beacd1628530958dd4d8f9404531748a973  railties-5.1.4.rc1.gem

As always, huge thanks to the many contributors who helped with this release!

Better docs, better performance, better Rails!

Hello everyone! This is Claudio with a recap of the main commits that made it into rails/rails this week. If you too want to contribute to Rails, this outstanding Active Record issue is a great place to start.

Temporarily point to a fork of SDoc

A work in progress to improve the documentation of Rails with a nicer theme, better SEO and faster generation time. Can you spot the difference between the current and the future version?

Minor tweaks in Active Storage documentation

Two weeks ago, Active Storage made it into rails/rails. This week its documentation has been improved to make it ready to ship with Rails 5.2.

Faster and more readable implementation of Hash#deep_merge

If you want to learn how to use benchmarks to prove that a commit can improve the performance of Rails, this is a great example.

Eager-load controller actions to reduce response time of the first request

The list of available actions for a controller is now eagerly loaded  to reduce response time of the first request and the memory footprint when running on forking server like Unicorn.

Load Parameters configurations on :action_controller only once

This PR fixes a regression introduced in 5.1.3 by which UnpermittedParameters were not raised as expected.

Check :scope input in Uniqueness validator

Without this patch, calling something like validates_uniqueness_of :code, scope: [archived: false] would cause NoMethodError with a trace into AR internals.

Add binary helper method to fixtures

You can now more easily use binary data as fixtures.

Add --skip-yarn option to the plugin generator

Don’t include yarn in your engines if you don’t need it.

Allow serialize with a custom coder on json and array columns

Better control on how to store your data.

Bump thor and blade

Thor 0.20 has new features you might want to look at.

That’s all for this week! Feel free to check the full list of commits if you are interested. Until next week!