1
0
Fork 0

Model dependecies

This commit is contained in:
magnolia-fan 2011-09-22 03:20:41 +04:00
parent da003cad12
commit c076efe860
5 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -1,2 +1,3 @@
class ArtistAlias < ActiveRecord::Base
belongs_to :artist
end

View File

@ -1,3 +1,4 @@
class Track < ActiveRecord::Base
belongs_to :album
belongs_to :artist, :through => :track_artists
end

View File

@ -1,2 +1,4 @@
class TrackArtist < ActiveRecord::Base
belongs_to :track
belongs_to :artist
end

View File

@ -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