From 24e5a8c51652301f9288024b0cd6807762867471 Mon Sep 17 00:00:00 2001 From: Espen Antonsen Date: Wed, 14 Apr 2010 01:00:48 -0400 Subject: [PATCH] fix set title. setting for heroku --- .gems | 1 + app/models/photo.rb | 8 ++++---- app/uploaders/file_uploader.rb | 4 ++++ config/balder.rb | 9 +++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gems b/.gems index c9e07b3..566aaaa 100644 --- a/.gems +++ b/.gems @@ -1,3 +1,4 @@ authlogic carrierwave aws-s3 +mini_exiftool diff --git a/app/models/photo.rb b/app/models/photo.rb index f128013..87524cf 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -12,8 +12,8 @@ class Photo < ActiveRecord::Base validates_presence_of :title before_validation :set_title - before_create :exif_read - before_update :exif_write # should only write if tags are changed as images can be large and thus ExifTool will take a while to write to the file + #before_create :exif_read + #before_update :exif_write # should only write if tags are changed as images can be large and thus ExifTool will take a while to write to the file attr_accessor :tag_list #attr_protected :path @@ -55,7 +55,7 @@ class Photo < ActiveRecord::Base def exif_info - photo = MiniExiftool.new(self.path_original) + photo = MiniExiftool.new(self.file.path) #photo.tags.sort.each do |tag| # puts tag.ljust(28) + photo[tag].to_s #end @@ -68,7 +68,7 @@ class Photo < ActiveRecord::Base private def set_title - self.title = self.file.filename.titleize unless self.title + self.title = self.file.file.basename.titleize unless self.title end def ensure_file diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index d0a1066..d9f7028 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -10,6 +10,10 @@ class FileUploader < CarrierWave::Uploader::Base #storage :file if ENV['S3_KEY'] storage :s3 + + def cache_dir + "#{RAILS_ROOT}/tmp/uploads" if ENV['HEROKU'] == 'true' + end else storage :file end diff --git a/config/balder.rb b/config/balder.rb index ca14e62..f2d6109 100644 --- a/config/balder.rb +++ b/config/balder.rb @@ -1,5 +1,6 @@ ENV['PUBLIC'] = 'true' -ENV['TITLE'] = 'photos' -#ENV['S3_KEY'] = '' -#ENV['S3_SECRET'] = '' -#ENV['S3_BUCKET'] = '' \ No newline at end of file +ENV['TITLE'] = 'photo' +#ENV['HEROKU'] = 'true' +#ENV['S3_KEY'] = '' +#ENV['S3_SECRET'] = '' +#ENV['S3_BUCKET'] = '' \ No newline at end of file