This Week in Rails

December 23, 2022

Rails on Docker, local? environment inquirer and more!

Hi there, this is Greg, bringing you the latest changes in Rails!

Only include all_queries default scopes on reload
This pull request changes the current behaviour on reload, which applies all the default scopes, if any are marked as all_queries: true. The correct behaviour is to only apply all_queries: true default scopes on reload.

Allow assets:precompile to be run in a production build step without passing in RAILS_MASTER_KEY
When compiling assets in production as part of an image build step, it's inconvenient to have to pass in the real RAILS_MASTER_KEY. So allow passing in a dummy secret_key_base, just like we do in development and test, via ENV["SECRET_KEY_BASE_DUMMY"] = 1. This will not give access to any of the real credentials or message verifiers, but allow the build step to complete, since it typically does not need it anyway.

Avoid unnecessary replacements in action text when the replacement node is unchanged
This is a performance improvement for the case where the replacement logic is based on some condition, and it returns the same unchanged node. And example and a benchmark can be found on the pull request.

Docked Rails CLI
Setting up Rails for the first time with all the dependencies necessary can be daunting for beginners. Docked Rails CLI uses a Docker image to make it much easier, requiring only Docker to be installed. 

Add default Dockerfiles
This pull request adds Docker files by default to new apps: Dockerfile, .dockerignore, bin/docker-entrypoint. These files can be skipped with --skip-docker. They're intended as a starting point for a production deploy of the application. Not intended for development (use the above mentioned Docked Rails for that). You can see more details about using it on the pull request.

Add Message{Encryptors,Verifiers}#transitional
This commit adds a transitional attribute to ActiveSupport::MessageEncryptors and ActiveSupport::MessageVerifiers. Setting it to true will swap the first two rotations when building a message encryptor/verifier. 
This can be useful when performing a rolling deploy of an application, wherein servers that have not yet been updated must still be able to verify messages from updated servers. 

Add Rails.env.local?
This pull requests adds a shorthand for Rails.env.development? || Rails.env.test?.

Add support for pattern argument to ActiveRecord::Relation#none?/#any?/#one?
The Enumerable versions of the #none?, #any?, and #one? predicate methods each take an optional pattern argument instead of a block, but the ActiveRecord::Relation versions didn't before this change.

23 people contributed to Rails this past week! Merry Christmas and see you next week with our yearly special

About This Week in Rails

Your weekly inside scoop of interesting commits, pull requests and more from Rails.