Fix trying to write non-existent image remote URL attribute on preview cards (#14181)

Regression from #14145
This commit is contained in:
Eugen Rochko
2020-06-29 17:59:04 +02:00
committed by GitHub
parent fa183a51ab
commit 1b198d6489
2 changed files with 152 additions and 145 deletions

View File

@ -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}!")