extract method

pull/7286/head
ulferts 6 years ago
parent 957b3d2800
commit 614430f71f
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 22
      app/services/add_attachment_service.rb

@ -55,16 +55,18 @@ class AddAttachmentService
ActiveRecord::Base.transaction do
attachment.save!
if container.respond_to? :add_journal
# reload to get the newly added attachment
container.attachments.reload
container.add_journal author
# We allow invalid containers to be saved as
# adding the attachments does not change the validity of the container
# but without that leeway, the user needs to fix the container before
# the attachment can be added.
container.save!(validate: false)
end
add_journal if container.respond_to? :add_journal
end
end
def add_journal
# reload to get the newly added attachment
container.attachments.reload
container.add_journal author
# We allow invalid containers to be saved as
# adding the attachments does not change the validity of the container
# but without that leeway, the user needs to fix the container before
# the attachment can be added.
container.save!(validate: false)
end
end

Loading…
Cancel
Save