2009-06-03 01:33:39 +02:00
|
|
|
class Collection < ActiveRecord::Base
|
|
|
|
has_many :collection_albums
|
|
|
|
has_many :albums, :through => :collection_albums
|
2009-06-12 01:04:57 +02:00
|
|
|
attr_accessor :album_list
|
2009-06-03 01:33:39 +02:00
|
|
|
|
2010-12-13 05:17:49 +01:00
|
|
|
validates :title, :presence => true
|
|
|
|
|
2009-06-11 13:05:09 +02:00
|
|
|
def to_param
|
2009-06-16 01:18:42 +02:00
|
|
|
"#{id}-#{title.parameterize}"
|
2009-06-11 13:05:09 +02:00
|
|
|
end
|
2009-08-06 15:01:39 +02:00
|
|
|
|
2009-06-12 01:04:57 +02:00
|
|
|
def album_list=(albums)
|
2009-08-06 15:01:39 +02:00
|
|
|
self.albums = Album.find(albums.map{|album|album[0]})
|
2009-06-12 01:04:57 +02:00
|
|
|
end
|
|
|
|
|
2009-06-11 13:05:09 +02:00
|
|
|
end
|