Rails 7.1.5.1 (December 10, 2024)
- No changes.
Rails 7.1.5 (October 30, 2024)
- No changes.
Rails 7.1.4.2 (October 23, 2024)
- No changes.
Rails 7.1.4.1 (October 15, 2024)
- No changes.
Rails 7.1.4 (August 22, 2024)
Preserve
--asset-pipeline propshaftwhen runningapp:update.Zacharias Knudsen
Allow string keys for SQLCommenter.
Ngan Pham
Fix derived foreign key to return correctly when association id is part of query constraints.
Varun Sharma
Show warning for
secret_key_basein development too.fatkodima
Fix sanitizer vendor configuration in 7.1 defaults.
In apps where
rails-html-sanitizerwas not eagerly loaded, the sanitizer default could end up
being Rails::HTML4::Sanitizer when it should be set toRails::HTML5::Sanitizer.Mike Dalessio, Rafael Mendonça França
Revert the use of
Concurrent.physical_processor_countin default Puma configWhile for many people this saves one config to set, for many others using
a shared hosting solution, this cause the default configuration to spawn
way more workers than reasonable.There is unfortunately no reliable way to detect how many cores an application
can realistically use, and even then, assuming the application should use
all the machine resources is often wrong.Jean Boussier
Rails 7.1.3.4 (June 04, 2024)
- No changes.
Rails 7.1.3.3 (May 16, 2024)
- No changes.
Rails 7.1.3.2 (February 21, 2024)
- No changes.
Rails 7.1.3.1 (February 21, 2024)
- No changes.
Rails 7.1.3 (January 16, 2024)
Make sure
config.after_routes_loadedhook runs on boot.Rafael Mendonça França
Fix
config.log_levelnot being respected when using aBroadcastLoggerÉdouard Chin
Fix isolated engines to take
ActiveRecord::Base.table_name_prefixinto consideration.
This will allow for engine defined models, such as inside Active Storage, to respect
Active Record table name prefix configuration.Chedli Bourguiba
The
bin/rails app:templatecommand will no longer add potentially unwanted
gem platforms viabundle lock --add-platform=...commands.Jonathan Hefner
Rails 7.1.2 (November 10, 2023)
Fix running
db:system:changewhen app has no Dockerfile.Hartley McGuire
If you accessed
config.eager_load_pathsand friends, later changes to
config.pathswere not reflected in the expected auto/eager load paths.
Now, they are.This bug has been latent since Rails 3.
Fixes #49629.
Xavier Noria
Rails 7.1.1 (October 11, 2023)
Ensures the Rails generated Dockerfile uses correct ruby version and matches Gemfile.
Abhay Nikam
Rails 7.1.0 (October 05, 2023)
- No changes.
Rails 7.1.0.rc2 (October 01, 2023)
Always set the Rails logger to be an instance of
ActiveSupport::BroadcastLogger.Edouard Chin
Rails 7.1.0.rc1 (September 27, 2023)
Require
concurrent-rubyinconfig/puma.rbso that Puma can boot in
production whenWEB_CONCURRENCYis not explicitly specified.Fixes #49323.
Matt Brictson
Raise error when generating attribute with dangerous name.
The following will now raise an error as
saveandhashare already
defined by Active Record.$ bin/rails generate model Post save $ bin/rails generate model Post hash
Petrik de Heus
Rails 7.1.0.beta1 (September 13, 2023)
Add ability to show slow tests to the test runner
$ bin/test --profile # additionally prints 10 (default) slowest tests # or $ bin/test --profile 20 # prints 20 slowest tests
fatkodima
rails new --javascriptgenerator now supports Bun$ rails new my_new_app --javascript=bun
Jason Meller
bin/setup uses
buninstead ofyarnwhen generated an app with bunUse
bun installonbin/setupwhen usingbun.Cadu Ribeiro
config/application.rbnow includesconfig.autoload_lib(ignore: %w(assets tasks))
In practice, this means that new 7.1 applications autoload from
libout of the box.Xavier Noria
Add an option to start rails console in sandbox mode by default
sandbox_by_defaultoption is added to start rails console in sandbox
mode by default. With this option turned on,--no-sandboxmust be
specified to start rails in non-sandbox mode.Note that this option is ignored when rails environment is development
or test.Shouichi Kamiya
Omit
webdriversgem dependency fromGemfiletemplateSean Doyle
Support filtering tests by line ranges
The new syntax allows you to filter tests by line ranges. For example, the
following command runs tests from line 10 to 20.$ rails test test/models/user_test.rb:10-20
Shouichi Kamiya, Seonggi Yang, oljfte, Ryohei UEDA
Update default scaffold templates to set 303 (See Other) as status code
on redirect for the update action for XHR requests other than GET or POST
to avoid issues (e.g browsers trying to follow the redirect using the
original request method resulting in double PATCH/PUT)Guillermo Iguaran
The new
config.autoload_lib_onceis similar toconfig.autoload_lib,
except that it addslibtoconfig.autoload_once_pathsinstead.By calling
config.autoload_lib_once, classes and modules inlibcan be
autoloaded, even from application initializers, but won’t be reloaded.Please, see further details in the autoloading
guide.Xavier Noria
Add
config.action_dispatch.debug_exception_log_levelto configure the log
level used byActionDispatch::DebugExceptions.The default is
:fatal, but withload_defaults "7.1"the default will be
:error.Hartley McGuire
Add
DATABASEoption torailties:install:migrationsThis allows you to specify which database the migrations should be copied to
when runningrails railties:install:migrations.$ rails railties:install:migrations DATABASE=animals
Matthew Hirst
The new method
config.autoload_lib(ignore:)provides a simple way to
autoload fromlib:# config/application.rb config.autoload_lib(ignore: %w(assets tasks))
Please, see further details in the autoloading
guide.Xavier Noria
Don’t show secret_key_base for
Rails.application.config#inspect.Before:
Rails.application.config.inspect "#"
After:
Rails.application.config.inspect "#"
Petrik de Heus
Deprecate calling
Rails.application.secrets.Rails
secretshave been deprecated in favor ofcredentials.
CallingRails.application.secretsshould show a deprecation warning.Petrik de Heus
Store
secret_key_baseinRails.configfor local environments.Rails
secretshave been deprecated in favor ofcredentials.
For the local environments thesecret_key_baseis now stored in
Rails.config.secret_key_baseinstead of the soft deprecated
Rails.application.secrets.secret_key_base.Petrik de Heus
Enable force_ssl=true in production by default: Force all access to the app over SSL,
use Strict-Transport-Security, and use secure cookiesJustin Searls, Aaron Patterson, Guillermo Iguaran, Vinícius Bispo
Add engine’s draw paths to application route set, so that the application
can draw route files defined in engine paths.Gannon McGibbon
Support
VISUALenvironment variable for commands which open an editor,
and prefer it overEDITOR.Summer ☀️
Add engine’s
test/fixturespath tofixture_pathsinon_loadhook if
path exists and is under the Rails application root.Chris Salzberg
bin/rails app:templatenow runsbundle installand anyafter_bundle
blocks after the template is executed.Jonathan Hefner and Gerry Caulfield
Enable passing column size to migration generator
Previously you could pass a limit to the migration generator:
rails generate migration CreateAuthor name:text{65535}Now, a size attribute can be passed to the migration generator:
rails generate migration CreateAuthor name:text{medium}This generates a migration which includes the size attribute:
class CreateAuthor < ActiveRecord::Migration[7.1] def change create_table :authors do |t| t.text :name, size: :medium end end end
Josh Broughton, Hartley McGuire
Trying to set a config key with the same name of a method now raises:
config.load_defaults = 7.0 # NoMethodError: Cannot assign to `load_defaults`, it is a configuration method
Xavier Noria
Deprecate
secrets:edit/showand removesecrets:setupbin/rails secrets:setuphas been deprecated since Rails 5.2 in favor of
credentials. This command has been removed.bin/rails secrets:showandbin/rails secrets:edithave been deprecated
in favor of credentials.Run
bin/rails credentials:helpfor more informationPetrik de Heus
bin/rails --helpwill now list only framework and plugin commands. Rake
tasks defined inlib/tasks/*.rakefiles will no longer be included. For a
list of those tasks, userake -T.Jonathan Hefner
Allow calling
bin/rails restartoutside of app directory.The following would previously fail with a “No Rakefile found” error.
$ blog/bin/rails restart
Petrik de Heus
Support prerelease rubies in Gemfile template if RubyGems version is 3.3.13 or higher.
Yasuo Honda, David Rodríguez
Autoloading setup honors root directories manually set by the user.
This is relevant for custom namespaces. For example, if you’d like classes
and modules underapp/servicesto be defined in theServicesnamespace
without an extraapp/services/servicesdirectory, this is now enough:# config/initializers/autoloading.rb # The namespace has to exist. # # In this example we define the module on the spot. Could also be created # elsewhere and its definition loaded here with an ordinary `require`. In # any case, `push_dir` expects a class or module object. module Services; end Rails.autoloaders.main.push_dir("#{Rails.root}/app/services", namespace: Services)
Check the autoloading guide for further details.
Xavier Noria
Railties now requires the irb gem as a dependency, which means when you install Rails, irb will also
be installed as a gem. Rails will then use the installed version of irb for its console instead of
relying on Ruby’s built-in version.
This ensures that Rails has access to the most up-to-date and reliable version of irb for its console.Stan Lo
Use infinitive form for all rails command descriptions verbs.
Petrik de Heus
Credentials commands (e.g.
bin/rails credentials:edit) now respect
config.credentials.content_pathandconfig.credentials.key_pathwhen set
inconfig/application.rborconfig/environments/#{Rails.env}.rb.Before:
bin/rails credentials:editignoredRAILS_ENV, and would always editconfig/credentials.yml.enc.bin/rails credentials:edit --environment foowould create and editconfig/credentials/foo.yml.enc.- If
config.credentials.content_pathorconfig.credentials.key_pathwas set,bin/rails credentials:editcould not be used to edit the credentials. Editing credentials required usingbin/rails encrypted:edit path/to/credentials --key path/to/key.
After:
bin/rails credentials:editwill edit the credentials file that the app would load for the currentRAILS_ENV.bin/rails credentials:editrespectsconfig.credentials.content_pathandconfig.credentials.key_pathwhen set inconfig/application.rborconfig/environments/#{Rails.env}.rb.bin/rails credentials:edit --environment foowill create and editconfig/credentials/foo.yml.encifconfig.credentials.content_pathhas not been set for thefooenvironment. Ultimately, it will edit the credentials file that the app would load for thefooenvironment.
Jonathan Hefner
Add descriptions for non-Rake commands when running
rails -h.Petrik de Heus
Show relevant commands when calling help
When running
rails -hor justrailsoutside a Rails application,
Rails outputs all options for running therails newcommand. This can be
confusing to users when they probably want to see the common Rails commands.Instead, we should always show the common commands when running
rails -h
inside or outside a Rails application.As the relevant commands inside a Rails application differ from the
commands outside an application, the help USAGE file has been split to
show the most relevant commands for the context.Petrik de Heus
Add Rails::HealthController#show and map it to /up for newly generated applications.
Load balancers and uptime monitors all need a basic endpoint to tell whether the app is up.
This is a good starting point that’ll work in many situations.DHH
Only use HostAuthorization middleware if
config.hostsis not emptyHartley McGuire
Raise an exception when a
before_action‘s “only” or “except” filter
options reference an action that doesn’t exist. This will be enabled by
default but can be overridden via config.# config/environments/production.rb config.action_controller.raise_on_missing_callback_actions = false
Jess Bees
Use physical processor count as the default Puma worker count in production.
This can be overridden by settingENV["WEB_CONCURRENCY"]or editing the
generated “config/puma.rb” directly.DHH
Add 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 (see Docked Rails for that).Example:
$ docker build -t app . $ docker volume create app-storage $ docker run --rm -it -v app-storage:/rails/storage -p 3000:3000 --env RAILS_MASTER_KEY= app
You can also start a console or a runner from this image:
$ docker run --rm -it -v app-storage:/rails/storage --env RAILS_MASTER_KEY= app console
To create a multi-platform image on Apple Silicon to deploy on AMD or Intel and push to Docker Hub for user/app:
$ docker login -u $ docker buildx create --use $ docker buildx build --push --platform=linux/amd64,linux/arm64 -t .
DHH, Sam Ruby
Add ENV[“SECRET_KEY_BASE_DUMMY”] for starting production environment with a generated secret base key,
which can be used to run tasks likeassets:precompilewithout making the RAILS_MASTER_KEY available
to the build process.Dockerfile layer example:
RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile
DHH
Show descriptions for all commands in Rails help
When calling
rails helpmost commands missed their description. We now
show the same descriptions as shown inrails -T.Petrik de Heus
Always generate the storage/ directory with rails new to ensure there’s a stable place to
put permanent files, and a single mount point for containers to map. Then default sqlite3 databases
to live there instead of db/, which is only meant for configuration, not data.DHH
Rails console now disables
IRB’s autocompletion feature in production by default.Setting
IRB_USE_AUTOCOMPLETE=truecan override this default.Stan Lo
Add
config.precompile_filter_parameters, which enables precompilation of
config.filter_parametersusingActiveSupport::ParameterFilter.precompile_filters.
Precompilation can improve filtering performance, depending on the quantity
and types of filters.config.precompile_filter_parametersdefaults totruefor
config.load_defaults 7.1and above.Jonathan Hefner
Add
after_routes_loadedhook toRails::Railtie::Configurationfor
engines to add a hook to be called after application routes have been
loaded.MyEngine.config.after_routes_loaded do # code that must happen after routes have been loaded end
Chris Salzberg
Send 303 See Other status code back for the destroy action on newly generated
scaffold controllers.Tony Drake
Add
Rails.application.deprecatorsas a central point to manage deprecators
for an application.Individual deprecators can be added and retrieved from the collection:
Rails.application.deprecators[:my_gem] = ActiveSupport::Deprecation.new("2.0", "MyGem") Rails.application.deprecators[:other_gem] = ActiveSupport::Deprecation.new("3.0", "OtherGem")
And the collection’s configuration methods affect all deprecators in the
collection:Rails.application.deprecators.debug = true Rails.application.deprecators[:my_gem].debug # => true Rails.application.deprecators[:other_gem].debug # => true
Additionally, all deprecators in the collection can be silenced for the
duration of a given block:Rails.application.deprecators.silence do Rails.application.deprecators[:my_gem].warn # => silenced (no warning) Rails.application.deprecators[:other_gem].warn # => silenced (no warning) end
Jonathan Hefner
Move dbconsole logic to Active Record connection adapter.
Instead of hosting the connection logic in the command object, the
database adapter should be responsible for connecting to a console session.
This patch moves #find_cmd_and_exec to the adapter and exposes a new API to
lookup the adapter class without instantiating it.Gannon McGibbon, Paarth Madan
Add
Rails.application.message_verifiersas a central point to configure
and create message verifiers for an application.This allows applications to, for example, rotate old
secret_key_base
values:config.before_initialize do |app| app.message_verifiers.rotate(secret_key_base: "old secret_key_base") end
And for libraries to create preconfigured message verifiers:
ActiveStorage.verifier = Rails.application.message_verifiers["ActiveStorage"]
Jonathan Hefner
Support MySQL’s ssl-mode option for the dbconsole command.
Verifying the identity of the database server requires setting the ssl-mode
option to VERIFY_CA or VERIFY_IDENTITY. This option was previously ignored
for the dbconsole command.Petrik de Heus
Delegate application record generator description to orm hooked generator.
Gannon McGibbon
Show BCC recipients when present in Action Mailer previews.
Akshay Birajdar
Extend
routes --grepto also filter routes by matching against path.Example:
$ bin/rails routes --grep /cats/1 Prefix Verb URI Pattern Controller#Action cat GET /cats/:id(.:format) cats#show PATCH /cats/:id(.:format) cats#update PUT /cats/:id(.:format) cats#update DELETE /cats/:id(.:format) cats#destroyOrhan Toy
Improve
rails runneroutput when given a file path that doesn’t exist.Tekin Suleyman
config.allow_concurrency = falsenow use aMonitorinstead of aMutexThis allows to enable
config.active_support.executor_around_test_caseeven
whenconfig.allow_concurrencyis disabled.Jean Boussier
Add
routes --unusedoption to detect extraneous routes.Example:
$ bin/rails routes --unused Found 2 unused routes: Prefix Verb URI Pattern Controller#Action one GET /one(.:format) action#one two GET /two(.:format) action#two
Gannon McGibbon
Add
--parentoption to controller generator to specify parent class of job.Example:
bin/rails g controller admin/users --parent=admin_controllergenerates:class Admin::UsersController < AdminController # ... end
Gannon McGibbon
In-app custom credentials templates are now supported. When a credentials
file does not exist,rails credentials:editwill now try to use
lib/templates/rails/credentials/credentials.yml.ttto generate the
credentials file, before falling back to the default template.This allows e.g. an open-source Rails app (which would not include encrypted
credentials files in its repo) to include a credentials template, so that
users who install the app will get a custom pre-filled credentials file when
they runrails credentials:edit.Jonathan Hefner
Except for
devandtestenvironments, newly generated per-environment
credentials files (e.g.config/credentials/production.yml.enc) now include
asecret_key_basefor convenience, just asconfig/credentials.yml.enc
does.Jonathan Hefner
--no-*options now work with the app generator’s--minimaloption, and
are both comprehensive and precise. For example:$ rails new my_cool_app --minimal Based on the specified options, the following options will also be activated: --skip-active-job [due to --minimal] --skip-action-mailer [due to --skip-active-job, --minimal] --skip-active-storage [due to --skip-active-job, --minimal] --skip-action-mailbox [due to --skip-active-storage, --minimal] --skip-action-text [due to --skip-active-storage, --minimal] --skip-javascript [due to --minimal] --skip-hotwire [due to --skip-javascript, --minimal] --skip-action-cable [due to --minimal] --skip-bootsnap [due to --minimal] --skip-dev-gems [due to --minimal] --skip-system-test [due to --minimal] ... $ rails new my_cool_app --minimal --no-skip-active-storage Based on the specified options, the following options will also be activated: --skip-action-mailer [due to --minimal] --skip-action-mailbox [due to --minimal] --skip-action-text [due to --minimal] --skip-javascript [due to --minimal] --skip-hotwire [due to --skip-javascript, --minimal] --skip-action-cable [due to --minimal] --skip-bootsnap [due to --minimal] --skip-dev-gems [due to --minimal] --skip-system-test [due to --minimal] ...
Brad Trick and Jonathan Hefner
Add
--skip-dev-gemsoption to app generator to skip adding development
gems (likeweb-console) to the Gemfile.Brad Trick
Skip Active Storage and Action Mailer if Active Job is skipped.
Étienne Barrié
Correctly check if frameworks are disabled when running app:update.
Étienne Barrié and Paulo Barros
Delegate model generator description to orm hooked generator.
Gannon McGibbon
Execute
rails runnerscripts inside the executor.Enables error reporting, query cache, etc.
Jean Boussier
Avoid booting in development then test for test tasks.
Running one of the rails test subtasks (e.g. test:system, test:models) would
go through Rake and cause the app to be booted twice. Now all the test:*
subtasks are defined as Thor tasks and directly load the test environment.Étienne Barrié
Deprecate
Rails::Generators::Testing::Behaviourin favor ofRails::Generators::Testing::Behavior.Gannon McGibbon
Allow configuration of logger size for local and test environments
config.log_file_sizeDefaults to
100megabytes.Bernie Chiu
Enroll new apps in decrypted diffs of credentials by default. This behavior
can be opted out of with the app generator’s--skip-decrypted-diffsflag.Jonathan Hefner
Support declarative-style test name filters with
bin/rails test.This makes it possible to run a declarative-style test such as:
class MyTest < ActiveSupport::TestCase test "does something" do # ... end end
Using its declared name:
$ bin/rails test test/my_test.rb -n "does something"
Instead of having to specify its expanded method name:
$ bin/rails test test/my_test.rb -n test_does_something
Jonathan Hefner
Add
--jsand--skip-javascriptoptions torails new--jsalias torails new --javascript ...Same as
-j, e.g.rails new --js esbuild ...--skip-jsalias torails new --skip-javascript ...Same as
-J, e.g.rails new --skip-js ...Dorian Marié
Allow relative paths with leading dot slash to be passed to
rails test.Fix
rails test ./test/model/post_test.rbto run a single test file.Shouichi Kamiya and oljfte
Deprecate
config.enable_dependency_loading. This flag addressed a limitation of theclassicautoloader and has no effect nowadays. To fix this deprecation, please just delete the reference.Xavier Noria
Define
config.enable_reloadingto be!config.cache_classesfor a more intuitive name. Whileconfig.enable_reloadingandconfig.reloading_enabled?are preferred from now on,config.cache_classesis supported for backwards compatibility.Xavier Noria
Add JavaScript dependencies installation on bin/setup
Add
yarn installto bin/setup when using esbuild, webpack, or rollout.Carlos Ribeiro
Use
controller_class_pathinRails::Generators::NamedBase#route_urlThe
route_urlmethod now returns the correct path when generating
a namespaced controller with a top-level model using--model-name.Previously, when running this command:
$ bin/rails generate scaffold_controller Admin/Post --model-name Post
the comments above the controller action would look like:
# GET /posts def index @posts = Post.all end
afterwards, they now look like this:
# GET /admin/posts def index @posts = Post.all end
Fixes #44662.
Andrew White
No longer add autoloaded paths to
$LOAD_PATH.This means it won’t be possible to load them with a manual
requirecall, the class or module can be referenced instead.Reducing the size of
$LOAD_PATHspeed-uprequirecalls for apps not usingbootsnap, and reduce the
size of thebootsnapcache for the others.Jean Boussier
Remove default
X-Download-OptionsheaderThis header is currently only used by Internet Explorer which
will be discontinued in 2022 and since Rails 7 does not fully
support Internet Explorer this header should not be a default one.Harun Sabljaković
Add .node-version files for Rails apps that use Node.js
Node version managers that make use of this file:
https://github.com/shadowspawn/node-version-usage#node-version-file-usageThe generated Dockerfile will use the same node version.
Sam Ruby
Please check 7-0-stable for previous changes.