Replaced by `#lease_connection` to better reflect what it does.
`ActiveRecord::Base#connection` is deprecated in the same way
but without a removal timeline nor a deprecation warning.
Inside the Active Record test suite, we do remove `Base.connection`
to ensure it's not used internally.
Some callsites have been converted to use `with_connection`,
some other have been more simply migrated to `lease_connection`
and will serve as a list of callsites to convert for
https://github.com/rails/rails/pull/50793
Ref: https://github.com/rails/rails/pull/51083
The introduction of `ActiveRecord::Base.with_connection` somewhat broke
some expectations, namely that calling `.connection` would cause the
connection to be permenently leased, hence that future calls to it
would return the same connection, with all it's possible environmental
changes.
So any call to `.connection`, even inside `.with_connection` should
cause the lease to be sticky, and persist beyond the `with_connection`
block.
Also rename `.connection` into `.lease_connection`, as to make it
more explicit.
```ruby
assert_equal "Ruby on Rails", web_sites(:rubyonrails).name
assert_equal "Ruby on Rails", fixture(:web_sites, :rubyonrails).name
```
This was brought to me by someone with a `Metadata` model. The fixtures
accessor being `metadata` which conflicts with the `metadata` method
recently added in `Minitest`.
* Set `action_mailer.default_url_options` values in `development` and `test`.
Prior to this commit, new Rails applications would raise
`ActionView::Template::Error` if a mailer included a url built with a
`*_path` helper.
Since we already know [new apps will be served on `localhost:3000`][new
apps], we set this as the value in `development`.
In an effort to remain consistent with existing patters, we set the
`host` to `www.example.com` in `test.
[new apps]: 47300002db/README.md (L81)
* Update railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
---------
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
Extracted from: https://github.com/rails/rails/pull/50793
Right now quoting table or column names requires a leased Adapter
instance, even though none of the implementations actually requires
an active connection.
The idea here is to move these methods to the class so that the quoting
can be done without leasing a connection or even needing the connection
to ever have been established.
I also checked `activerecord-sqlserver-adapter` and `oracle-enhanced`
gems, and neither need an active connection.
Fixed incorrect documentation for `ActiveSupport::Logger.logger_outputs_to?`. The method expects the first argument to be a Logger object and subsequent variadic arguments to be either IO objects or strings representing file paths.
Also corrected the sample code in CHANGELOG.md, which previously only passed a single argument, not reflecting the correct usage.
related PR: https://github.com/rails/rails/pull/51125
rails/rails#51131 introduced parameter filtering for redirects. We
didn't account for invalid URIs though, and it changes the behaviour of
redirect_to to raise URI errors when we try to filter a bad URI.
Instead, we should fallback to filtering bad URIs entirely to preserve behaviour.
* Update ActiveStorage Docs
Included documentation around usage of the `key` parameter in `.attach` method to specify folders within S3 Bucket for organizing files and storing them with intuitive names.
* Update active_storage_overview.md
lint correction - removed trailing whitespace
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
Extracted from: https://github.com/rails/rails/pull/50793
Similar to the recent refactoring of schema caches, rather than to directly
hold a connection, they now hold a pool and checkout a connection when needed.