This commit is contained in:
r888888888
2018-05-26 12:58:19 -07:00
parent c054784302
commit ca842cc6d9
4 changed files with 27 additions and 7 deletions

View File

@@ -180,8 +180,13 @@ class Artist < ApplicationRecord
def save_urls
if url_string && saved_change_to_url_string?
self.urls = url_string.scan(/[^[:space:]]+/).uniq.map do |url|
self.urls.find_or_create_by(url: url)
Artist.transaction do
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
end
end
end
end