public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
Quick fix for creating thumbnails
satoshi (author)
Tue Oct 07 05:06:57 -0700 2008
commit  9d754014744b039d82e3e55b3cc7f7c35c16ab08
tree    35ed9ecdebc776142edd7ebc952ba224eec1e356
parent  cda2d14898347fa949c8e7d7ddbf9b1b7298fe7f
...
167
168
169
170
 
171
172
173
...
274
275
276
277
 
 
278
279
280
281
282
 
283
284
285
...
167
168
169
 
170
171
172
173
...
274
275
276
 
277
278
279
280
 
281
 
282
283
284
285
0
@@ -167,7 +167,7 @@ module Technoweenie # :nodoc:
0
         base.after_save :after_process_attachment
0
         base.after_destroy :destroy_file
0
         base.after_validation :process_attachment
0
- base.attr_accessible
0
+ base.attr_accessible :uploaded_data
0
         if defined?(::ActiveSupport::Callbacks)
0
           base.define_callbacks :after_resize, :after_attachment_saved, :before_thumbnail_saved
0
         end
0
@@ -274,12 +274,12 @@ module Technoweenie # :nodoc:
0
       def create_or_update_thumbnail(temp_file, file_name_suffix, *size)
0
         thumbnailable? || raise(ThumbnailError.new("Can't create a thumbnail if the content type is not an image or there is no parent_id column"))
0
         returning find_or_initialize_thumbnail(file_name_suffix) do |thumb|
0
- thumb.attributes = {
0
+ thumb.temp_paths.unshift temp_file
0
+ thumb.send(:'attributes=', {
0
             :content_type => content_type,
0
             :filename => thumbnail_name_for(file_name_suffix),
0
- :temp_path => temp_file,
0
             :thumbnail_resize_options => size
0
- }
0
+ }, false)
0
           callback_with_args :before_thumbnail_saved, thumb
0
           thumb.save!
0
         end

Comments

    No one has commented yet.