Rails 5.1.7 has been released

Hi everyone,

I am happy to announce that Rails 5.1.7 has been released.

CHANGES since 5.1.6

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

To see a summary of changes, please read the release on GitHub:


Full listing

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


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.1.7:

$ shasum -a 256 *-5.1.7.gem
c344a1b4edd4108b93b341343106e73466d8bbf0a79c926a62c74f6b22984ec1  actioncable-5.1.7.gem
f053e043f0e83b7758b56af7fe21aa3ab2f61787e2edc6a1198acc8d3645fbbe  actionmailer-5.1.7.gem
a2406a8346f95294ad9342c1535e2cc4f04e7c084e71359bae224650581bd17f  actionpack-5.1.7.gem
871ca9cae0524e937543510104555c1e8d87f180b14ce0a03fe62c69012a5244  actionview-5.1.7.gem
f44a4691d7fca6b0f08c2dbd5c81110f428d5c8ade9c6a6b8e09c7984741a55c  activejob-5.1.7.gem
709bb03d9c950353e8f70e0ed4f12154c346d492e5bf6ea53b515413c740fc1e  activemodel-5.1.7.gem
5a1f4bf7b5e5c05a3e21e9207f1336eab026b3dfd794a37eeee4a4c81cfe8544  activerecord-5.1.7.gem
216db77f40e41dab82328321c375f519de8c898dcc2b88a5319d3608928fd07e  activesupport-5.1.7.gem
8d7f527c446de3f99ec506e6a680c42c38979a44b37beb15f7d451a33e74dcf5  rails-5.1.7.gem
c874ebb682f628cfe075c3b9762d3b2ff1a04585c25a2f4eb3840c4b29d73e72  railties-5.1.7.gem

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

Rails 5.1.7.rc1 has been released!

Hi everyone,

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

This is going to be the final bug fix release for the 5.1 series, so please make sure you test the release candidates to make sure no regressions are found.

If no regressions are found, expect the final release on Wednesday, March 27, 2019. If you find one, please open an issue on GitHub and mention me (@rafaelfranca) on it, so that we can fix it before the final release.

CHANGES since 5.1.6

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

To see a summary of changes, please read the release on GitHub:

5.1.7.rc1 CHANGELOG

Full listing

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


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.1.7.rc1:

$ shasum -a 256 *-5.1.7.rc1.gem
4b50c8213b6b4846f35d994991458da797185f9e0ca92063131a59f5890bb5e3  actioncable-5.1.7.rc1.gem
65c84a566b58a4faf10e02abe4dd09f5d7101cfb79896cbf3bfb0d623c06f07b  actionmailer-5.1.7.rc1.gem
8c230b21146c155793c874da49f032be595343df4e8cca59b4be172d10b95e5a  actionpack-5.1.7.rc1.gem
cd9b9acf025c99c113155192622ebb333c729e8a99dea43d91c6016bdb287e0b  actionview-5.1.7.rc1.gem
3308343948ca041b58068c34cc312de1b867f46c8feaf997421ce4e182d8a2e7  activejob-5.1.7.rc1.gem
9ad6fc7f9cb05b5d38462672315b4b05863d263ba46b035367d7e290dc7dd160  activemodel-5.1.7.rc1.gem
4940e5f4c2e4cc1ca8e2d3d41ebf514e5d315e1f39884d518e22e8600b7b0d22  activerecord-5.1.7.rc1.gem
26e956e7b2d16e0783f48ae05e6822da2aabac96ecf1f3b78d6e035145f10b6c  activesupport-5.1.7.rc1.gem
ca0f895446ceece1d904e96bedff90224e715acb9f124b60ffc9ac1b568ed07d  rails-5.1.7.rc1.gem
bbd0b366890da1c6baa3bd68c3132e499f53143351b7ab382c661a0fb9f07ac1  railties-5.1.7.rc1.gem

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

Rails 5.2.3.rc1 has been released!

Hi everyone,

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

If no regressions are found, expect the final release on Wednesday, March 27, 2019. If you find one, please open an issue on GitHub and mention me (@rafaelfranca) on it, so that we can fix it before the final release.

CHANGES since 5.2.2

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

To see a summary of changes, please read the release on GitHub:

5.2.3.rc1 CHANGELOG

Full listing

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


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.2.3.rc1:

$ shasum -a 256 *-5.2.3.rc1.gem
353ad8bf6ae456c3392d2d38817263b242eafb8c36a56dc39ef168dba85913cf  actioncable-5.2.3.rc1.gem
489322d94165891a2aa3a5274f54fbba75f06d669d490bd265170356bcf8dd7e  actionmailer-5.2.3.rc1.gem
7b55fa598d3c4826112d482bafb2f34c94457bc142a2989cae56fdd4282212c8  actionpack-5.2.3.rc1.gem
43c69fc7e4f0088d67db47b048785d00568706e5959bd634d9c4b8c59bba6f85  actionview-5.2.3.rc1.gem
350e2e04dc5e18c69f8d9aa2b784bc30c170d4b8ea152fbb3a4a28423b6c639b  activejob-5.2.3.rc1.gem
c4e52ac78e393f30c3f553f772942d0e6b5834baa3046a4c7a5db028f894b414  activemodel-5.2.3.rc1.gem
8c4858ccee67a420f5c4cea16c558e8502eb7fa72808d532dc1ef33586fb23b1  activerecord-5.2.3.rc1.gem
c83e05b7906ae4f9c657d46fc007acb3ef6c2ad602e633980bc22e59a0c7aa5c  activestorage-5.2.3.rc1.gem
88e334741d202bf95ebdf0d8db54b7abb299ecdb6e516d7b5033c19ad6f3dedf  activesupport-5.2.3.rc1.gem
419a56071b85f5496de89810700d6bfab8c373ceb8beccc3052bbb6c8e3fc6b3  rails-5.2.3.rc1.gem
1a907c12473dec3cd543099245d7a23c045d4b52f92eb35f38fee211ee613084  railties-5.2.3.rc1.gem

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

Security fixes, bulk insert and upsert, seeds replanting

Hello. This is Wojtek here bringing you the exciting updates from Rails.

Security fix releases of Rails

Rails,,,, and 6.0.0.beta3 have been released containing important security fixes. Note that with 6.0 release only Rails 6.x.y and Rails 5.2.x are guaranteed to receive both major and minor security fixes by Rails core.

Active Record adds “insert_all” and “upsert_all” methods

It’s now possible to insert many records at once within one SQL statement. You can check summary of this feature in Josef’s blog post.

Rails command “db:seed:replant” added

Bring back clean state of database seeds with this simple command without redoing the database structure.

Active Support adds Enumerable “including” method

Self-explained by an example:

[ 1, 2, 3 ].including(4, 5) => [ 1, 2, 3, 4, 5 ]

For parity, method without was renamed to excluding.

54 people contributed to Rails in the last 2 weeks. You can see the full list of changes here.

Until next time!

Rails,,,, and 6.0.0.beta3 have been released!

Hello everyone!

Rails,,,, and 6.0.0.beta3 have been released! These contain the following important security fixes. It is recommended that users upgrade as soon as possible:

Rails and 6.0.0.beta3 also contain the following fix:

The released versions can be found in the usual locations, and you can find a list of changes on GitHub:

If you’re not able to upgrade immediately workarounds have been provided on the advisory pages in the Google Rails Security Group.

We’ve done our best to minimize any impact to your applications, but if you run in to any issues, please file a ticket and we’ll do our best to help!

If you run in to security issues, please follow the reporting process which can be found here.


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

$ shasum -a 256 **
5ec3df89a6796f18006198b95e6849ea736bc6170da0daf7d8cec9e388a49ca3  actionmailer-
50f296dfd8cfbb071fa1008c5157ed22871dbe0ddddc4cc1ec9c1235a66eb466  actionpack-
373d6065baf091996e0d6d36b99080ceeee323038fcf218ff39f2e839195fb74  actionview-
b21e40e0c147fc24c939fa1b4b1e3677ffae22b9c125a881ba587a6d7260c14b  activejob-
63d898086a8d2d0a493ebb4d8c9376c6f9d3dfe846f7aa1f70615a6e5a063db0  activemodel-
b7e0744484c8a9fe2c123657cfb5bbf678657555eeeeacf0d449ff0f228f3d1e  activerecord-
264782453d1912cf99f80b6bbf3f2e0e0592874e740e2c66f4dbad02903a78ed  activesupport-
b4b6536187eab61696358d851e043d60be3fc8313da67815467bb4968a8e9bfb  rails-
35b430dfd63028401c19dbfe4b319bebd59ea0b5a6b818d85731aa9a7e104eae  railties-
$ shasum -a 256 **
525621c9bde0e729e566e9ebdaf23945cf0cc0b11e731f3f74c7d4d839e97b01  actioncable-
f5e616088e556244bf6cf6e6236e9a7bbef0d2bd2627b97c19c53096130b4756  actionmailer-
3ad093d8fcc08163b4ce38136b933c4c38c4973c872b155023fec11523a35eed  actionpack-
1c52732589d776ba01590233b44c33f679ec62c9bada89ebed3755066eb00823  actionview-
d122d5414f485713eabd4e5e866b1a238b1179ec5fd33d81cb2c5f6d751ce9df  activejob-
395d43d408239936668f04cab80bc64b50b08e414fe866664e1bf717e265aaca  activemodel-
8eb57c48689536545e08b87a6b45b5d2b30a19f1cc06d2772aad9694083ae11a  activerecord-
bc336a970b5d1c2c2e9e1494afd6ff585680dbab6f12d95acd17ee1be8d6de09  activesupport-
3ce2eac8fa58ce138e3e2a2fa9b544c8f43128e0c24d0a1d8d751b3a515bb82a  rails-
4dc24c2dbe4b89ce7c2975cbdb601fcb868de3f1992c00629991033a86059c18  railties-
$ shasum -a 256 **
381b8945ed2bf7aea3e56be8ec6265a9db0e6443d5d1be169484b91ba3041926  actioncable-
e1c30d19963b365db87daf122620dc9cb006938f0f6d3ac28e0f2da511fd1b6c  actionmailer-
56c17b7a665a8b1ac816d7ed9fda5d36e605fc4951b0b9455bf464f2ba34d08c  actionpack-
127da709aa88c749c3723b7fc3b02bbaf22767f1114d4910cc626eba6027e7e5  actionview-
d6511d6cdf23920bfa1b0062966d5a2468cc8ee705b921e2ef0547bee541c9ac  activejob-
b324ff341f2410a509e655000206b521fed43ff295de2589eb5eeed18d931985  activemodel-
3f45f3bbdaf0e6583853393adac564457def668fc26023093e061dc6b977eebd  activerecord-
ed88feb866ad705e79cd5ca6c8f3dd39d8571df02abf0d10b34889576c93bb4f  activesupport-
8e721f8e6c7ea0dfd6dbf7fe215f2c40b1de5d104b6cf5d1e1313dc02be640e9  rails-
a385a8620eb3a5f11c2ac2c2d50cc2dba268dfc0e26b07a566b03a2dbff17ddf  railties-
$ shasum -a 256 **
4125771d4a3c6fb9a38d1617eae08abdb2a0418c2f23d8f891bfa1f3736d15ca  actioncable-
622e4fae71442c5d7df7e77eeb932f17c27093055a737d4a7a5b4e0d407c4c47  actionmailer-
8a223ad2f06e51ee624993589b77dc4401645bb3bda3faa5ab04758cf39cab4d  actionpack-
3f9c1868cd07708bddec82a83f8091d48e6f529bb4c7c25167e428f50aeef278  actionview-
b8271b919108a743bbd79d6da3d3ee9bcdd7529294175eaf7a16d26caf984251  activejob-
55d56bcaefcff47d85bfac98d40e57d5ac0b923575abb5fdd0dd6a064f381381  activemodel-
e21d5ff1f2a0f79aa446e84563978f628c42caf1db7b4804c43e585bf28bb600  activerecord-
4664ace24b43227a42d943cfc8aae59dbe79091ee70cf7be257b4553e50fd8bf  activestorage-
d0a7b92b46e34de7cca05ed74d9659b205f91a0a7fda9f2ea5a3f53ae00b2a81  activesupport-
e45c26eff3d7bdfa989ab884754f25d4a274b4b6324df9d9a4a7168cc32ccbe0  rails-
44b2cfe87f78cb3069362a15c8c3b49ff5a02ea01d60dd2685e1112a9e01e938  railties-
$ shasum -a 256 *6.0.0.beta3.gem*
749a4eed1702e463fef97b2dfa0aed961b6a13931f50ac92bcc176b98bb5159e  actioncable-6.0.0.beta3.gem
b7c4936ffa9697a5d6ea397a28d1f67f3847aebe76a8fa717c61f8ee81d3efcc  actionmailbox-6.0.0.beta3.gem
be8af2a7d9af39f4ee0252b5104204c6b36d7d2ca0ac0bdc0063230c247e711a  actionmailer-6.0.0.beta3.gem
7d070d5853f19c685d22a790d6be919356727a281ab2b30c8104c30dc5e045f4  actionpack-6.0.0.beta3.gem
faf1f28e70a9faf04ac2077fb4e2f518ac76a29e8e1c487f3d9658118553eaf0  actiontext-6.0.0.beta3.gem
91c72834addba79ff315c56f2924ee1a8fba99db45c65ccd0406e4b611d7b1a4  actionview-6.0.0.beta3.gem
c8f76f01156bc6542d17e116b4c9971f969f663badacd2e0cf036baaff796ae9  activejob-6.0.0.beta3.gem
3bc73125ba7105391779ee41e929a7d2b989a733efe86c84594654ae26a7e95a  activemodel-6.0.0.beta3.gem
d31e3c6ae3207dd27bc4fed178dd43c592b1a3d42f3df3f0780abbb27e8ea3f1  activerecord-6.0.0.beta3.gem
d4a743473431153c4f502409bb8d9dc57d9252687f85a94a932772eed6f0f95d  activestorage-6.0.0.beta3.gem
7193da2b92e4f9da95e4cfa2a878911cb420f535343613df0398dfe60ff9c868  activesupport-6.0.0.beta3.gem
b08df88e745edaca9b38162e115bc14935bbf6749eaf4809745c9679d7816c07  rails-6.0.0.beta3.gem
24aa0b8df380fc847ae0eb4d951eeb3b4f9d388aff84eab5f7a43c477c423c95  railties-6.0.0.beta3.gem

reselect, negative enum scopes and more!

Why hello there! Tim here bringing you all the latest and greatest from This Week In Rails.

Negative scopes for enum values

Some sugar around enum values allows you to make negative scopes such as

Post.not_drafted # => where.not(status: :drafted)

New method: reselect

Allows you to change a previously set select statement in the same manner to rewhere and reorder, e.g.

Post.select(:title, :body).reselect(:created_at)

#size fixed when using SELECT DISTINCT

#size_ would ignore the DISTINCT in the select, giving a different result to #count. This is now fixed!

Active Storage’s _blob loading fixed

If you attached a has_one_attachment attachment, you may have found that the attachment’s _blob method would have returned nil. This was fixed by assigning the blob when the attachment is assigned.

22 people contributed to Rails since our last issue; you can see the full list of changes here.

Until next week!

Rails 6.0.0 beta2 released

We’re marching one step closer to the final release of Rails 6 with this second beta. We’ve fixed a bunch of issues and added a few minor features, but the big change is switching to Xavier’s new Zeitwerk library for handling autoloading. It’s a big, structural change to how we require dependencies at runtime, and it should remove a bunch of the legacy warts, and the weird gotchas. Xavier wrote up a long piece on it you should check out.

Otherwise things are much the same as they were with the first beta. I encourage you to read the release notes for that to understand the big picture of 6.0.

You can peruse all the 532 commits we’ve made since the first beta.

We are still kinda on track with our published timeline for the final Rails 6.0 release, so consult that plan for your migration planning, but please do help us already by testing your application on beta2! I’d also encourage anyone with a moderate level of Rails experience to start any new app using beta2, rather than the Rails 5.2.x series. Basecamp and Shopify are both already running Rails 6.0.0.beta2 in production. This isn’t some rickety-shack release.

This release, and all releases leading up to Rails 6.0 final, was shepherded by release manager Rafael França with support by Kasper Timm Hansen.

Thanks again to everyone who keeps working on making Rails better!

Zeitwerk integration in Rails 6 (Beta 2)

The second beta of Rails 6 is about to ship, and includes Zeitwerk integration.

While Rails 6 final is going to have proper documentation about it, this post will help understanding this feature meanwhile.


  • You can now robustly use constant paths in class and module definitions:

    # Autoloading in this class' body matches Ruby semantics now.
    class Admin::UsersController < ApplicationController
      # ...
  • All known use cases of require_dependency have been eliminated.

  • Edge cases in which the autoloaded constant depended on execution order are gone.

  • Autoloading is thread-safe in general, not just for the currently supported use cases with explicit locks like web requests. For example, you can now write multi-threaded scripts to be run by bin/rails runner and they will autoload just fine.

Also, applications get some performance benefits for the same price:

  • Autoloading a constant no longer involves walking autoload paths looking for a relative match in the file system. Zeitwerk does one single pass and autoloads everything using absolute file names. In addition, that single pass descends into subdirectories lazily, only when the namespaces are used.

  • When an application is reloaded due to changes in the file system, code in the autoload paths of engines that were loaded as gems won’t be reloaded anymore.

  • Eager loading eager loads not only the application, but also the code of any gem that is managed by Zeitwerk.

Autoloading modes

Rails 6 ships with two autoloading modes: :zeitwerk and :classic. They are set using the new configuration point config.autoloader.

Zeitwerk mode is the default in Rails 6 for CRuby, automatically enabled by

load_defaults "6.0"

in config/application.rb.

Applications can opt-out putting

config.autoloader = :classic

after the line that loads the defaults.

State of the API

While a first API for Zeitwerk mode is converging, this is still a bit exploratory right now. Please, check the current documentation if your version of Rails is newer than 6.0.0.beta2.

Autoload paths

The configuration point for autoload paths remains config.autoload_paths, and if you push by hand to ActiveSupport::Dependencies.autoload_paths during application initialization, that will also work.


All known use cases of require_dependency have been eliminated. In principle, you should just delete all these calls in the code base. See also the next section about STIs.


Active Record needs to have STI hierarchies fully loaded in order to generate correct SQL. Preloading in Zeitwerk was designed for this use case:

# config/initializers/preload_vehicle_sti.rb

autoloader = Rails.autoloaders.main
sti_leaves = %w(car motorbike truck)

sti_leaves.each do |leaf|

By preloading the leaves of the tree, autoloading will take care of the entire hierarchy upwards following superclasses.

These files are going to be preloaded on boot, and on each reload.


In Zeitwerk mode, Rails.autoloaders is an enumerable that has two Zeitwerk instances called main, and once. The former is the one managing your application, and the latter manages engines loaded as gems, as well as anything in the somewhat unknown config.autoload_once_paths (whose future is not bright). Rails reloads with main, and once is there just for autoloading and eager loading, but does not reload.

Those instances are accessible respectively as


but since Rails.autoloaders is an enumerable, there won’t be too many use cases for direct access, probably.

Inspecting autoloaders activity

If you want to see the autoloaders working, you can throw

Rails.autoloaders.logger = method(:puts)

to config/application.rb after the framework defaults have been set. In addition to a callable, Rails.autoloaders.logger= accepts also anything that responds to debug with arity 1, like regular loggers do.

If you want to see the activity of Zeitwerk for all instances in memory (both Rails’ and others that might be managing gems), you can set

Zeitwerk::Loader.default_logger = method(:puts)

at the top of config/application.rb, before Bundle.require.

Backwards incompatibility

  • For files below the standard concerns directories (like app/models/concerns), Concerns cannot be a namespace. That is, app/models/concerns/geolocatable.rb is expected to define Geolocatable, not Concerns::Geolocatable.

  • Once the application has booted, autoload paths are frozen.

  • Directories in ActiveSupport::Dependencies.autoload_paths that do not exist on boot are ignored. We are referring here to the actual elements of the array only, not to their subdirectories. New subdirectories of autoload paths that existed at boot are picked up just fine as always. (This may change for final.)

  • A file that defines a class or module that acts as a namespace, needs to define the class or module using the class and module keywords. For example, if you have app/models/hotel.rb defining the Hotel class, and app/models/hotel/pricing.rb defining a mixin for hotels, the Hotel class must be defined with class, you cannot do Hotel = Class.new { ... } or Hotel = Struct.new { ... } or anything like that. Those idioms are fine in classes and modules that do not act as namespaces.

  • A file should define only one constant in its namespace (but can define inner ones). So, if app/models/foo.rb defines Foo and also Bar, Bar won’t be reloaded, but reopened when Foo is reloaded. This is strongly discouraged in classic mode anyway though, the convention is to have one single main constant matching the file name. You can have inner constants, so Foo may define an auxiliary internal class Foo::Woo.

Active Record bug fixes, faster Date#advance, and more!

Hello everyone! This is Eugene, with a selection of interesting improvements to Rails merged in the past week.

Don’t load app environment when editing credentials

Support for per-environment credentials is coming in Rails 6.0, but adding a new environment wasn’t always easy: if your application accessed credentials during boot, the credentials:edit command would fail to run, which would in turn prevent you from adding the missing credentials. Oops!

All queries should return correct results even if they include large numbers

When prepared statements are enabled, querying an integer column with an out-of-range value causes an error in the underlying database driver. To work around this issue, Active Record used to refuse to run the query and always return a negative result, e.g. ActiveRecord::RecordNotFound.

This approach worked for simple queries, but gave incorrect results for more complex ones. Out-of-range values are now converted to “impossible” predicates instead (e.g. WHERE 1=0), which allows the query to run without an error while still producing the correct result.

Speaking of large numbers: this pull request, opened 18 months ago, was number 30,000 on the Rails repository. 🎈

Fix year value when casting a multi-parameter time hash

Values stored in TIME columns in the database are mapped to Time objects in Ruby. The latter includes date parts, where the former doesn’t; to deal with this discrepancy, a default date of January 1st, 2000 is always assigned.

When a multi-parameter time value—as generated by the time_select helper—was assigned to an attribute, its year would be set to 1970 instead, producing a different result depending on where the value came from.

With this fix, time attributes have fully joined us in the 21st century. 🖖

Faster and more memory-efficient Date#advance

This method was copying its options hash unnecessarily. Now that it doesn’t, it’s both faster and allocates less memory.

28 people contributed to Rails since our last issue; you can see the full list of changes here.

Until next week!

Rails 6.0.0 beta1, and more

Daniel here, writing from chilly NYC to bring you the latest Rails news.

Rails 6.0.0 beta1

Many thanks to everyone who helped get this amazing release together. It includes Action Text and Action Mailbox, both recently merged into Rails. Try it out today!

New command to change databases

Have you ever created a new Rails app without specifying the database system upfront, then realized you need to switch over from SQLite to PostgreSQL? That change is now as simple as running: bin/rails db:system:change --to=postgresql

Improved multi-db errors

I think we can all appreciate helpful error messages. Many thanks to Eileen for helping us out, and for all of the incredible work to support multiple databases.

Action Cable Testing

The test helpers from the action-cable-testing gem are now fully merged into Rails. Testing your cables has never been easier.

Endless ranges in where conditions

Ruby 2.6 introduced endless ranges. In Rails 6 we will be able to use them in where conditions: features.where(awesomeness: 10..)

Don’t watch your parents

Before this change, if a directory to be watched was not present in the project, Rails would watch that directory’s parent directory instead. In some cases this could lead to watching the entire Rails root directory.

72 people contributed to Rails over the past month. There are still plenty of open issues that could use your help. Will we see your name on the list next week?