clear artist urls before saving url string (fixes #3731)

This commit is contained in:
Albert Yi
2018-06-04 17:37:43 -07:00
parent dd6848912c
commit 52de1fb981
2 changed files with 9 additions and 4 deletions

View File

@@ -181,11 +181,9 @@ class Artist < ApplicationRecord
def save_urls
if url_string && saved_change_to_url_string?
Artist.transaction do
self.urls.clear
self.urls = url_string.scan(/[^[:space:]]+/).uniq.map do |url|
# need to do these shenanigans to properly handle prefixes
aurl = self.urls.find_or_create_by(url: ArtistUrl.strip_prefixes(url))
aurl.update(url: url)
aurl
self.urls.find_or_create_by(url: url)
end
end
end