Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attachment_fu + ruby 1.9.1 #25

Open
ghost opened this issue Sep 3, 2010 · 10 comments
Open

attachment_fu + ruby 1.9.1 #25

ghost opened this issue Sep 3, 2010 · 10 comments

Comments

@ghost
Copy link

ghost commented Sep 3, 2010

Something goes wrong when I upload:

/!\ FAILSAFE /!\ 2010-09-03 15:21:19 +0200
Status: 500 Internal Server Error
can't convert nil into Integer
/files/sources/rails/customer-service/vendor/plugins/attachment_fu/init.rb:7:in sprintf' /files/sources/rails/customer-service/vendor/plugins/attachment_fu/init.rb:7:inmake_tmpname'
/usr/lib64/ruby/1.9.1/tmpdir.rb:132:in create' /usr/lib64/ruby/1.9.1/tempfile.rb:134:ininitialize'
/usr/lib64/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/utils.rb:486:in new' /usr/lib64/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/utils.rb:486:inblock in parse_multipart'
[...]

On ruby 1.8 is ok.

@technoweenie
Copy link
Owner

Judging by the error message, something is nil that shouldn't be. Looks like the behavior of Tempfiles changed. Send me a pull request if you find a fix that works on ruby 1.8 and 1.9. Thanks!

@ghost
Copy link
Author

ghost commented Sep 5, 2010

In attachment_fu/init.rb, in method make_tmpname second argument n is nil in ruby 1.9 when I upload file but don't know why:

def make_tmpname(basename, n)
ext = nil
sprintf("%s%d-%d%s", basename.to_s.gsub(/.\w+$/) { |s| ext = s; '' }, $$, n, ext)
end

@papayaah
Copy link

was wondering if anyone has a solution to the problem? this happens on Ruby 1.9/Rails 3.0

@ivanpoznyak
Copy link

adding n ||= 0 before calling sprintf (in attachment_fu/init.rb) seems to solve the problem. I can't say if this is a "valid" fix in terms of whether it breaks something, or whether it is working in ruby 1.8.7.

@anassirk
Copy link

anassirk commented Oct 1, 2010

thanx, @ivanpoznyak. works for me.

@ippa
Copy link

ippa commented Nov 15, 2010

I've tried both fixes I've found for this issue:
n ||= 0

and
sprintf("%s%d-%s%s", basename.to_s.gsub(/.\w+$/) { |s| ext = s; '' }, $$, n, ext)
instead of
sprintf("%s%d-%d%s", basename.to_s.gsub(/.\w+$/) { |s| ext = s; '' }, $$, n, ext)

in both cases the crashing stops but something happens with my thumbnails.. they all get the same size as the original picture. Not sure if this is repeatable by others or if has something to do with my particular setup. Investigating further ...

@daronco
Copy link

daronco commented Feb 21, 2011

Another simple solution that seems to work well:

sprintf('%s%d-%d%s', File::basename(basename, ext), $$, n.to_i, ext)

Notice the:

n.to_i

At: http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions

@johnnypez
Copy link

Did anyone get thumbnails to work after implementing the fix for this issue? I think attachment_fu is attachment_fubar on ruby 1.9 :(

@enortham
Copy link

Johnypez, I upgraded my app to Ruby 1.9.2 and had to make the fix mentioned above. I was then able to upload images but they weren't being resized nor where the thumbnails being created. I realized that the processor wasn't able to load ImageMagick. After uninstalling and reinstalling rmagick I then had a seg fault and had to also reinstall ImageMagick based on http://stackoverflow.com/questions/2838307/why-is-this-rmagick-call-generating-a-segmentation-fault. Once ImageMagick was up and running fine attachment fu properly resized the images and created thumbnails under 1.9.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants