2009-05-22 14:13:46 +02:00
|
|
|
class Album < ActiveRecord::Base
|
2009-05-22 22:38:52 +02:00
|
|
|
has_many :photos, :dependent => :destroy
|
2009-05-22 21:04:41 +02:00
|
|
|
|
|
|
|
validates_uniqueness_of :path, :message => "Album already exsists on disc"
|
2009-05-22 22:38:52 +02:00
|
|
|
|
|
|
|
before_destroy :destroy_directory
|
2009-05-22 21:04:41 +02:00
|
|
|
|
2009-05-22 22:38:52 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def destroy_directory
|
|
|
|
#puts "DELETE DIRECTORY " + APP_CONFIG[:photos_path] + self.path
|
|
|
|
#Dir.delete( APP_CONFIG[:photos_path] + self.path + "/" ) if File.exists?( APP_CONFIG[:photos_path] + self.path )
|
|
|
|
#Dir.delete( APP_CONFIG[:thumbs_path] + self.path ) if File.exists?( APP_CONFIG[:thumbs_path] + self.path )
|
|
|
|
end
|
2009-05-22 14:13:46 +02:00
|
|
|
end
|