Attachment_fu validation error

I have this class:

class Logo < ActiveRecord::Base
has_one :something

 has_attachment :content_type => :image,
                :storage      => :db_file,
                :max_size     => 500.kilobytes
                :thumbnails   => {:web => '150x100', :pdf =>

‘150x100’},
:processor => ‘MiniMagick’

 validates_as_attachment

end

OK, logos are working great in the application, resizing, storage,
retrieval, …, fine. But the validation of existing logos fails with
(complete trace below)

Logo.find(:first).valid?
NameError: undefined local variable or method `full_filename’ for
#Logo:0x3561ed8

And unfortunately that is triggered by something’s
validates_associated if no logo is uploaded in its edition. I don’t
see why valid? ends up calling set_size_from_temp_path, sizes were
correctly computed and stored on creation:

pp Logo.find(:first)
#<Logo:0x35593f0
@attributes=
{“content_type”=>“image/jpeg”,
“size”=>“187697”,
“thumbnail”=>nil,
“id”=>“1”,
“height”=>“768”,
“db_file_id”=>“3”,
“filename”=>“img_1651.jpeg”,
“parent_id”=>nil,
“width”=>“1024”}>

This happens with all logos in the application, isn’t that
suspicious? I’ve not diffed svn with the installed version but both
CHANGELOGs start with

  • April 2, 2007 *

– fxn

Logo.find(:first).valid?
NameError: undefined local variable or method full_filename' for #<Logo:0x3561ed8> from ./script/../config/../config/../vendor/rails/ activerecord/lib/active_record/base.rb:1860:inmethod_missing’
from ./script/…/config/…/config/…/vendor/plugins/
attachment_fu/lib/technoweenie/attachment_fu.rb:276:in temp_paths' from ./script/../config/../config/../vendor/plugins/ attachment_fu/lib/technoweenie/attachment_fu.rb:270:intemp_path’
from ./script/…/config/…/config/…/vendor/plugins/
attachment_fu/lib/technoweenie/attachment_fu.rb:236:in
save_attachment?' from ./script/../config/../config/../vendor/plugins/ attachment_fu/lib/technoweenie/attachment_fu.rb:339:inset_size_from_temp_path’
from ./script/…/config/…/config/…/vendor/rails/
activerecord/lib/active_record/callbacks.rb:333:in send' from ./script/../config/../config/../vendor/rails/ activerecord/lib/active_record/callbacks.rb:333:incallback’
from ./script/…/config/…/config/…/vendor/rails/
activerecord/lib/active_record/callbacks.rb:330:in each' from ./script/../config/../config/../vendor/rails/ activerecord/lib/active_record/callbacks.rb:330:incallback’
from ./script/…/config/…/config/…/vendor/rails/
activerecord/lib/active_record/callbacks.rb:295:in `valid?’
from (irb):16

On Jun 29, 2007, at 8:33 PM, Xavier N. wrote:

validates_associated if no logo is uploaded in its edition. I don’t
see why valid? ends up calling set_size_from_temp_path, sizes were
correctly computed and stored on creation:

I’ve seen something: that method is set as a before_validation,
that’s why it gets called. Following the traces the plugin tries to
determine whether the logo needs to be saved in save_attachment?
which in the end results in a call to temp_paths

def temp_paths
@temp_paths ||= (new_record? || !File.exist?(full_filename)) ?
[] : [copy_to_temp_file(full_filename)]
end

full_filename is implemented by the file system and s3 backends, but
it is missing in the database backend which is the one I am using. I
don’t know enough about the plugin at this moment to propose a
suitable fix, but at least I write a custom quick fix and go on with
the project.

– fxn