Paperclip Geometry NoMethodError

168 views
Skip to first unread message

Marc

unread,
Jun 14, 2010, 10:16:14 AM6/14/10
to Paperclip Plugin
Hi,

I sometimes get an NoMethodError "undefined method `[]' for
nil:NilClass" in vendor/plugins/paperclip/lib/paperclip/thumbnail.rb:
18:in `initialize' when uploading an image.

If uploading works the content of options are:

---
:whiny: true
:quality: 60
:convert_options: ""
:processors:
- :thumbnail
:geometry: 150x150>

and if not:

---
:whiny: true
:quality: 60
:convert_options: ""
:processors:
- :thumbnail

My model configuration is:

has_attached_file :source, :styles => {
:small => {
:geometry => "150x150>",
:quality => 60,
},
:mini => {
:geometry => "35x35>",
:quality => 40,
},
:list => {
:geometry => "64x64>",
:quality => 40,
}
}

I don't know why it somethings works and somethings not trying the
same image.

Please help.

Thanks

Marc

djnawara

unread,
Jun 29, 2010, 11:20:40 AM6/29/10
to Paperclip Plugin
I've got the same problem. It looks like the Paperclip::Style object
is not getting the geometry string on some requests, and I'm having
difficulty tracking down why.

The problem is exaggerated when I try to upload multiple files at
once.

Regards,
Dave

djnawara

unread,
Jun 30, 2010, 5:11:57 PM6/30/10
to Paperclip Plugin
I'm not sure how/why styles are reloading, but I changed style.rb:
18..21 and it's maybe fixed? The original code uses Hash delete to
retrieve values from the definitions.

@geometry = definition[:geometry]
@format = definition[:format]
@processors = definition[:processors]
@other_args = definition.reject {|key,value|
[:geometry, :format, :processors].include?(key)}

I'm uncertain on tests or I'd work on that...

Tim Harding

unread,
Jul 20, 2010, 1:07:01 PM7/20/10
to papercli...@googlegroups.com
Hi,

Further to this.

I was having the same difficulty when reprocessing files either through the rake task or using reprocess! directly.

Your patch solved that. Thank you.

This was only the case with the new style Hash based styles:

  has_attached_file :file, :styles => { 
      :medium => { :geometry => "300x300>", :format => :png },
      :thumb => { :geometry => "100x100>", :format => :png },
      :page => { :geometry => "800", :format => :png, :source_file_options => '-density 288', :convert_options => '-append' }
    }

Working w/ the legacy styles style worked fine:

has_attached_file :file, :styles => { :medium => ["300x300>", :png], :thumb => ["100x100>", :png], :page => ["800", :png] }

-Tim



--
Individuals over processes. Interactions over tools.

Agile Rails training from thoughtbot, the makers of Paperclip, Clearance, Shoulda, & Factory Girl:
http://thoughtbot.com/services/training

The Paperclip group:
http://groups.google.com/group/paperclip-plugin

To post to this group, send email to
papercli...@googlegroups.com

To unsubscribe from this group, send email to
paperclip-plug...@googlegroups.com



--
Tim Harding

Well Informed Ltd
Registered in England & Wales
Company number 06707839
Registered office: Suite 235, 77 Beak St, London, W1F 9DB

Thomas

unread,
Aug 15, 2010, 12:29:01 PM8/15/10
to Paperclip Plugin
As of the 15th of August 2010 this bug is still present and terribly
painful! paperclip is not suitable for a production environment! Or
devs have to make it clear in the documentation that one should use
the "legacy" styles definition mentioned by Tim.

Mariusz Droździel

unread,
Aug 16, 2010, 4:43:12 PM8/16/10
to Paperclip Plugin
The fix to clone the hash proposed earlier kinda fixed the problem for
me. I had no time to debug depper into paperclip, but after some
extensive testing I can say, that this is working now.
Reply all
Reply to author
Forward
0 new messages