diff --git a/app/models/artist.rb b/app/models/artist.rb index b370b18..d1eaddb 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,4 +1,6 @@ class Artist < ActiveRecord::Base has_many :albums, :order => 'has_pic DESC, year ASC, id ASC', :dependent => :destroy has_many :artist_links, :dependent => :destroy + has_many :artist_aliases, :dependent => :destroy + has_many :tracks, :through => :track_artists end diff --git a/app/models/artist_alias.rb b/app/models/artist_alias.rb index 70aa571..79dcbe6 100644 --- a/app/models/artist_alias.rb +++ b/app/models/artist_alias.rb @@ -1,2 +1,3 @@ class ArtistAlias < ActiveRecord::Base + belongs_to :artist end diff --git a/app/models/track.rb b/app/models/track.rb index c22fba8..61dd73f 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -1,3 +1,4 @@ class Track < ActiveRecord::Base belongs_to :album + belongs_to :artist, :through => :track_artists end diff --git a/app/models/track_artist.rb b/app/models/track_artist.rb index 168452f..2325bb5 100644 --- a/app/models/track_artist.rb +++ b/app/models/track_artist.rb @@ -1,2 +1,4 @@ class TrackArtist < ActiveRecord::Base + belongs_to :track + belongs_to :artist end diff --git a/lib/discogs.rb b/lib/discogs.rb index b19ab3d..8d506ad 100644 --- a/lib/discogs.rb +++ b/lib/discogs.rb @@ -12,7 +12,7 @@ class Discogs def self.process_artist node artist = Artist.new( :name => (node.css('name').first.text), - :pic_url => (node.css('images > image[type="primary"]').first.text unless node.css('images > image[type="primary"]').empty?), + :pic_url => (node.css('images > image[type="primary"]').first.attr('uri') unless node.css('images > image[type="primary"]').empty?), :status => 1 ) artist.save