Reputation: 3032
I am trying to add file uploads to my Rails 6 app and Active Storage. I followed this guide (https://gorails.com/episodes/direct-uploads-with-rails-active-storage)
It works perfect except that when you update the parent record and add additional flies all the previous ones are purged. Do you need to customize your controller or am I missing some simple configuration option here?
Upvotes: 1
Views: 1136
Reputation: 725
This is not a bug but intended behavior, and the behavior is still the same in Rails 7.0. The behavior can be changed on application level, by adding
config.active_storage.replace_on_assign_to_many = false
to config/application.rb
.
UPDATE: This configuration option is already deprecated in Rails 7.0, and will be removed in Rails 7.1. The apps will behave as if the option is set to true, and the decision to append or replace has to be made individually for each action. Here are some good viewpoints on how to do that.
Upvotes: 3
Reputation: 1238
This is a known issue in Rails 6.0.0rc1
https://github.com/rails/rails/issues/36374
I think they'll fix this via a config variable if I understood well.
Upvotes: 3