mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Clarify existing app behavior when being upgraded [ci skip]
Closes #39213.
This commit is contained in:
parent
ae46546ea3
commit
0ae8780c8c
1 changed files with 3 additions and 5 deletions
|
@ -531,7 +531,7 @@ When using the Classic Autoloader in Rails 6 application it is recommended to se
|
||||||
|
|
||||||
### Active Storage assignment behavior change
|
### Active Storage assignment behavior change
|
||||||
|
|
||||||
In Rails 5.2, assigning to a collection of attachments declared with `has_many_attached` appended new files:
|
With the configuration defaults for Rails 5.2, assigning to a collection of attachments declared with `has_many_attached` appends new files:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class User < ApplicationRecord
|
class User < ApplicationRecord
|
||||||
|
@ -549,8 +549,7 @@ user.highlights.first.filename # => "funky.jpg"
|
||||||
user.highlights.second.filename # => "town.jpg"
|
user.highlights.second.filename # => "town.jpg"
|
||||||
```
|
```
|
||||||
|
|
||||||
With the default configuration for Rails 6.0, assigning to a collection of attachments replaces existing files
|
With the configuration defaults for Rails 6.0, assigning to a collection of attachments replaces existing files instead of appending to them. This matches Active Record behavior when assigning to a collection association:
|
||||||
instead of appending to them. This matches Active Record behavior when assigning to a collection association:
|
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
user.highlights.attach(filename: "funky.jpg", ...)
|
user.highlights.attach(filename: "funky.jpg", ...)
|
||||||
|
@ -574,8 +573,7 @@ user.highlights.first.filename # => "funky.jpg"
|
||||||
user.highlights.second.filename # => "town.jpg"
|
user.highlights.second.filename # => "town.jpg"
|
||||||
```
|
```
|
||||||
|
|
||||||
Opt in to the new default behavior by setting `config.active_storage.replace_on_assign_to_many` to `true`.
|
Existing applications can opt in to this new behavior by setting `config.active_storage.replace_on_assign_to_many` to `true`. The old behavior will be deprecated in Rails 6.1 and removed in a subsequent release.
|
||||||
The old behavior will be deprecated in Rails 6.1 and removed in a subsequent release.
|
|
||||||
|
|
||||||
Upgrading from Rails 5.1 to Rails 5.2
|
Upgrading from Rails 5.1 to Rails 5.2
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue