Mass artist controller refactoring

This commit is contained in:
Gregory Eremin
2011-10-20 15:01:57 +04:00
parent 62d7d378bd
commit 73ce491479
9 changed files with 83 additions and 131 deletions
+10
View File
@@ -3,4 +3,14 @@ class Artist < ActiveRecord::Base
has_many :artist_links, :dependent => :destroy
has_many :artist_aliases, :dependent => :destroy
has_many :tracks, :through => :track_artists
after_initialize :prepare_description
def status_str
%w(loading ok fail)[self.status]
end
def prepare_description
self.desc.gsub! /[\[<].*?[\]>]/, ''
end
end
+12
View File
@@ -2,4 +2,16 @@ class Track < ActiveRecord::Base
belongs_to :album
has_many :track_artists
has_many :artists, :through => :track_artists
@duration
def duration
if self.length
time = self.length
time_m = (time / 60).floor
time_s = time - time_m * 60
time_m.to_s + ':' + (time_s < 10 ? '0' : '') + time_s.to_s
else
'0:00'
end
end
end