diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-07-07 23:25:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-07 23:25:33 -0400 |
commit | e8682c5bf051517b0b265e446aa1a7eccfd47bf7 (patch) | |
tree | cc04c8a28113bc0fa3748fdc6035d487e3e16af7 /activestorage/lib/active_storage/attached/changes/create_one_of_many.rb | |
parent | 0b534cd1c814a4db2d0aa283981f1d55e5e62d25 (diff) | |
download | rails-e8682c5bf051517b0b265e446aa1a7eccfd47bf7.tar.gz rails-e8682c5bf051517b0b265e446aa1a7eccfd47bf7.tar.bz2 rails-e8682c5bf051517b0b265e446aa1a7eccfd47bf7.zip |
Store newly-uploaded files on save rather than assignment
Diffstat (limited to 'activestorage/lib/active_storage/attached/changes/create_one_of_many.rb')
-rw-r--r-- | activestorage/lib/active_storage/attached/changes/create_one_of_many.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activestorage/lib/active_storage/attached/changes/create_one_of_many.rb b/activestorage/lib/active_storage/attached/changes/create_one_of_many.rb new file mode 100644 index 0000000000..7268e87316 --- /dev/null +++ b/activestorage/lib/active_storage/attached/changes/create_one_of_many.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module ActiveStorage + class Attached::Changes::CreateOneOfMany < Attached::Changes::CreateOne #:nodoc: + private + def find_attachment + record.public_send("#{name}_attachments").detect { |attachment| attachment.blob_id == blob.id } + end + end +end |