Tuesday, April 13, 2010

attachment_fu on Windows

When upload an image file with attachment_fu on windows, you will see there is an error such as 'Size is not included in the list' and you cannot upload the file to Amazon S3.

You can refer to the link "http://epirsch.blogspot.com/2008/01/fixing-attachmentfu-on-windows-like.html" to use attachment_fu_patch file but I cannot make it run because of lib path error.

Thus, I simply update the following three files and restart the server, which works great:
(1) %your_ruby_root%/lib/uby/1.8/tempfile.rb
def size
if @tmpfile
@tmpfile.fsync # added this line
@tmpfile.flush
@tmpfile.stat.size
else
0
end
end

(2)$your_project/vender/plugins/attachment/lib/technoweenie/attachment_fu.rb
def temp_data
if save_attachment?
f = File.new( temp_path )
f.binmode
return f.read
else
return nil
end
end

(3) $your_project/vender/plugins/attachment/lib/technoweenie/attachment_fu/backends/s3_backend.rb
def save_to_storage
if save_attachment?
S3Object.store(
full_filename,
(temp_path ? File.open(temp_path, "rb") : temp_data), # added , "rb"
bucket_name,
:content_type => content_type,
:access => attachment_options[:s3_access]
)
end

@old_filename = nil
true
end

Thursday, April 8, 2010

missing mislav-will_paginate

After you install 'will_paginate', you may see the strange error like:

Missing these required gems:
mislav-will_paginate

You're running:
ruby 1.8.7.72 at /usr/bin/ruby1.8
rubygems 1.3.5 at /home/ci/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.

And, even though you try to install 'mislav-will_paginate', it does not allow to install it.

Then, it is because you miss a source so that you need to add the following source as follows:

gem sources -a http://gems.github.com

Then, install:

gem install mislav-will_paginate