From 1b198d64890de3eed5562c9b485ed8cafbff059f Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 29 Jun 2020 17:59:04 +0200 Subject: Fix trying to write non-existent image remote URL attribute on preview cards (#14181) Regression from #14145 --- app/models/concerns/remotable.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/models') diff --git a/app/models/concerns/remotable.rb b/app/models/concerns/remotable.rb index 6fc1dcc26..53ebc0835 100644 --- a/app/models/concerns/remotable.rb +++ b/app/models/concerns/remotable.rb @@ -7,8 +7,8 @@ module Remotable def remotable_attachment(attachment_name, limit, suppress_errors: true, download_on_assign: true, attribute_name: nil) attribute_name ||= "#{attachment_name}_remote_url".to_sym - define_method("download_#{attachment_name}!") do - url = self[attribute_name] + define_method("download_#{attachment_name}!") do |url = nil| + url ||= self[attribute_name] return if url.blank? @@ -51,9 +51,9 @@ module Remotable define_method("#{attribute_name}=") do |url| return if self[attribute_name] == url && public_send("#{attachment_name}_file_name").present? - self[attribute_name] = url + self[attribute_name] = url if has_attribute?(attribute_name) - public_send("download_#{attachment_name}!") if download_on_assign + public_send("download_#{attachment_name}!", url) if download_on_assign end alias_method("reset_#{attachment_name}!", "download_#{attachment_name}!") -- cgit