From 2ddea72d7f2c4a1c14d3fc8b901934c92b376c89 Mon Sep 17 00:00:00 2001 From: Espen Antonsen Date: Sat, 1 Aug 2009 20:12:34 +0200 Subject: [PATCH] protected --- app/models/album.rb | 2 +- lib/scan.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/album.rb b/app/models/album.rb index 3aeceef..4745912 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -92,7 +92,7 @@ class Album < ActiveRecord::Base def create_folders Dir.mkdir( APP_CONFIG[:photos_path] + self.path ) unless File.exists?( APP_CONFIG[:photos_path] + self.path ) - Dir.mkdir( APP_CONFIG[:thumbs_path] + self.path.encode("ASCII-8BIT") ) unless File.exists?( APP_CONFIG[:thumbs_path] + self.path ) + Dir.mkdir( APP_CONFIG[:thumbs_path] + self.path ) unless File.exists?( APP_CONFIG[:thumbs_path] + self.path ) end def destroy_folders diff --git a/lib/scan.rb b/lib/scan.rb index 59080a1..a9811c2 100644 --- a/lib/scan.rb +++ b/lib/scan.rb @@ -18,7 +18,8 @@ module ScanFiles end if album.nil? puts "New album : " + File.basename( relpath ) - album = Album.new( :path => relpath ) + album = Album.new() + album.path = relpath unless album.save raise "unable to save album" end @@ -26,7 +27,9 @@ module ScanFiles photo = Photo.find_by_path( relfile ) if photo.nil? puts " New photo added " + relfile - photo = Photo.new( :album => album, :path => relfile ) + photo = Photo.new( ) + photo.album = album + photo.path = relfile unless photo.save raise "unable to save photo" end