Go back Active Storage

Append files in Active storage without removing existing


Solution 1  - introduce setter method on model that appends

# a/m/entry.rb
class Entry < ApplicationRecord
  has_many_attached :files

  def append_files=(attachables)
    files.attach(attachables)
  end
end

new files get appended 
# a/c/entries_controller.rb
def entry_params
  params.require(:entry).permit(append_files: [])
end

new files  replaced existing files

# a/c/entries_controller.rb
def entry_params
 
params.require(:entry).permit(files: []) end

-----------------------------------------

Solution 2  - Globally enable new files  should append


# config/application.rb
config.active_storage.replace_on_assign_to_many = false

new files get appended 

# a/c/entries_controller.rb
def entry_params
 
params.require(:entry).permit(files: []) end