Model dependecies
This commit is contained in:
parent
da003cad12
commit
c076efe860
|
@ -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
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
class ArtistAlias < ActiveRecord::Base
|
||||
belongs_to :artist
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
class Track < ActiveRecord::Base
|
||||
belongs_to :album
|
||||
belongs_to :artist, :through => :track_artists
|
||||
end
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
class TrackArtist < ActiveRecord::Base
|
||||
belongs_to :track
|
||||
belongs_to :artist
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue