* main: (746 commits)
Address QueryCacheTest#test_query_cache_does_not_allow_sql_key_mutation failure
Fixes ActiveStorage proxy downloads of files over 5mb in S3-like storage services
Fixes development Action Mailbox new mail form
Squash commits
Include the unexpected class in InvalidParameterKey message
Support unbounded time ranges for PostgreSQL
Fix CHANGELOG alignment [ci-skip]
Add ability to ignore tables by regexp for SQL schema dumps
Improve `rails s` error message when no server could be found.
Fix MySQL warning when creating Active Record's test databases
Add `--js` and --skip-javascript` options to `rails new`
Fix parsing operator classes for index columns in PostgreSQL
Fix rails test command to handle leading dot slash
Document that url_for can take classes
Don't change the encoding of frozen parameters
Update working_with_javascript_in_rails.md
Avoid query from calculations on contradictory relation
Fix MemoryStore#write(name, val, unless_exist: true) with expired entry
Provide pattern matching for ActiveModel
Stop autoclosing of PRs
...
Every time I write `config.cache_classes` I have to pause for a moment to make
sure I get it right. It makes you think.
On the other hand, if you read `config.enable_reloading = true`, does the
application reload? You do not need to spend 1 cycle of brain CPU to nod.
Now it's possible to write
audio_tag(user.audio_file)
video_tag(user.video_file)
Instead of
audio_tag(polymorphic_path(user.audio_file))
video_tag(polymorphic_path(user.video_file))
image_tag already supported that, so this follows the same pattern.
If for some reason the files that defined those constants were loaded
before the `after_initialize` block, the values of the configuration
would not be applied.
With this new implementation we always use the configuration value, so
the order things are defined doesn't matter.
ImageProcessingTransformer now offers a configurable allow-list for
transformation methods in addition to a configurable deny-list for arguments.
[CVE-2022-21831]
* Revert "Pass service_name param to DirectUploadsController"
This reverts commit 193289dbbe.
* Revert "Multi-service direct uploads in Action Text attachment uploads"
This reverts commit 0b69ad4de6.
They don't need to be streamed and by including
ActiveStorage::Streaming, they spin up new threads which can cause
problems with connection pools as detailed in #44242
The background
---
Configuration for replacing a collection was introduced in
[rails/rails#36716][].
However, since [rails/rails#42596][] has been merged, Rails 7.1 and
beyond will default to _replacing_ an Active Storage `has_many_attached`
relationship, as opposed to _appending to it_.
The problem
---
With replacement as the established precedent, it's currently a
challenge to replace an existing collection with an empty one.
The solution
---
This commit makes two changes.
The first is to Action View and its form building helpers. The change
draws inspiration from how an `<input type="checkbox">` field (or
collection of fields) is paired with an `<input type="hidden">` field to
represent the unchecked value. The change pairs any `<input type="file"
multiple="multiple">` elements with an `<input type="hidden">` element
to represent an empty collection. Like the [check_box][] form builder
method, the `file_field` method accepts an `include_hidden:` option to
skip the creation of the hidden element.
The second is to how Active Storage generates attribute assignment
methods through `has_many_attached`. With the possibility of an `<input
type="file">` field being paired with an `<input type="hidden"
value="">` field, the backing models need to be able to coerce an
"empty-ish" value into an empty list. For example:
```ruby
@user.highlights = [""]
@user.highlights # => []
```
When combined, these changes enable consumer applications to submit
"empty" collections to blank out existing attachments.
Support is configured through the
`config.active_storage.multiple_file_field_include_hidden` configuration
value, which defaults to `false`.
[check_box]: https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-check_box
[rails/rails#36716]: https://github.com/rails/rails/pull/36716
[rails/rails#42596]: https://github.com/rails/rails/pull/42596
As noted at https://github.com/rails/rails/pull/40842#issuecomment-895231378, the current implementation works great with the `processed` method, but doesn't work with other methods such as `key`. This PR fixes that.
Why is this fix necessary? Currently when you call `VariantWithRecord#key`, `key` gets called on `VariantWithRecord` -> `Attached::One` -> `Attachment` -> `Blob`. This results in n+1 calls to load the `Attachment`. But for this purpose we shouldn't need to load it, as the `VariantWithRecord` already knows about it relevant `Blob`. So this PR changes the method to call directly to that blob.
In the cast of bootstrapping a project for the first time without active storage, when running `rails app:update` this migration would result in trying to create the table twice.