# Attachment\_fu thumbnail not created

**URL:** <https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425>\
**Category:** Rails\
**Created:** [April 8, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425 "2007-04-08T22:55:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 8, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/1 "2007-04-08T22:55:24Z")

</div>

I followed the instructions on Mike C.'s weblog and everything  
works perfectly except the thumbnail column in my DB is alwas NULL.  
I’m using S3 as my storage system. Anyone else having this issue with  
thumbnails?

has\_attachment :content\_type =\> :image,  
:storage =\> :s3,  
:max\_size =\> 500.kilobytes,  
:resize\_to =\> ‘150x150\>’,  
:thumbnails =\> { :thumb =\> ‘40x40\>’ },  
:processor =\> ‘Rmagick’

validates\_as\_attachment

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 9, 2007, 7:13am UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/2 "2007-04-09T07:13:00Z")

</div>

I first started out with trying to use ImageScience. I followed the  
directions correctly on their website and within my app when I try to  
upload an image it shuts down mongrel/server with this error:

/Users/Bob/work/app/trunk/vendor/plugins/attachment\_fu/lib/  
technoweenie/attachment\_fu/processors/image\_science\_processor.rb:14:  
[BUG] Bus Error  
ruby 1.8.4 (2005-12-24) [i686-darwin8.8.1]

Abort trap

Fair enough, I’ll just try minimagick and see if that works. When I  
run: gem install mini\_magick I get this error:  
ERROR: While executing gem … (Errno::EACCES)  
Permission denied - /usr/local/lib/ruby/gems/1.8/cache/  
mini\_magick-1.2.0.gem

So it looks like Rmagick is the only one that is working but  
attachment\_fu is not saving thumbnails. Ideally I would like to use  
ImageScience but I cannot spend all day working on this image upload  
problem. Anyone know what I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 9, 2007, 5:55pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/3 "2007-04-09T17:55:10Z")

</div>

Anyone know why the thumbnails are not being created while everything  
else is working fine?

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 13, 2007, 1:18pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/4 "2007-04-13T13:18:57Z")

</div>

Hello,

On 9 Apr 2007, at 16:53, jko170 wrote:

> Anyone know why the thumbnails are not being created while everything  
> else is working fine?

I doubt this is the answer, but I thought I’d link it just in case it  
helps:

[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/)  
3c86abb8daa12cc6/079b85c99b22be2f

Regards,  
Andy S.

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 14, 2007, 2:08am UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/5 "2007-04-14T02:08:38Z")

</div>

try installing mini\_magick again but put a sudo in front:

sudo gem install mini\_magick

are you on a mac ?

I assume you are trying to install it locally and that you have the  
appropriate permissions.

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 15, 2007, 8:24pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/6 "2007-04-15T20:24:46Z")

</div>

Thanks for the replies. I installed mini magick correctly and  
thumbnails are still not generated. I doesn’t matter what image  
processor I use so I’m assuming that’s not the problem.

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 14, 2007, 5:14pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/7 "2007-04-14T17:14:29Z")

</div>

jko170 wrote:

> Anyone know why the thumbnails are not being created while everything  
> else is working fine?

I ran into this a few weeks ago using a Flash upload widget, and it  
turned out that the uploader wasn’t sending the proper MIME type –  
everything was application/octet-stream, so attachment\_fu wasn’t  
recognizing the file as an image.

I just rewrote the uploaded\_data method of attachment\_fu to check  
against a table mapping file extensions to MIME types when it found a  
file type of application/octet-stream. The hack seems to work for my  
purposes.

–Al Evans

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 15, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/8 "2007-04-15T21:00:51Z")

</div>

Here is all my code incase someone can spot something:

create\_table “photos” do |t|  
t.column :user\_id, :integer, :null =\> false  
t.column :content\_type, :string  
t.column :filename, :string  
t.column :thumbnail, :string  
t.column :size, :integer  
t.column :width, :integer  
t.column :height, :integer  
end

class Photo \< ActiveRecord::Base  
belongs\_to :user

has\_attachment :content\_type =\> :image,  
:storage =\> :s3,  
:max\_size =\> 500.kilobytes,  
:resize\_to =\> ‘150x150\>’,  
:thumbnails =\> { :thumb =\> [50, 50], :geometry =\>  
‘x50’ },  
:processor =\> ‘MiniMagick’

validates\_as\_attachment  
end

def create  
@user = User.new(params[:user])  
@photo = Photo.new(params[:photo])  
@user.photo = @photo

```
if @user.save && @photo.save
  flash[:notice] = 'User was successfully created.'
  redirect_to user_url(@user)
else
  render :action => "new"
end

```

end

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 16, 2007, 12:17am UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/9 "2007-04-16T00:17:17Z")

</div>

Hi,

You need to have a ‘parent\_id’ column in your photos table. This one  
had me scratching my head for a few hours too until I stumbled across  
this requirement of the plugin.

See the tutorial: [http://clarkware.com/cgi/blosxom/2007/02/24](http://clarkware.com/cgi/blosxom/2007/02/24)

He doesn’t mention that parent\_id is required however.

Guy

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 16, 2007, 8:38am UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/10 "2007-04-16T08:38:46Z")

</div>

That fixed it. Thanks Guy!

One more quick question: Do you know how to make the thumbnail and  
images resize to an exact size? I guess that would require cropping?

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [April 26, 2007, 4:02pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/11 "2007-04-26T16:02:42Z")

</div>

hi just wondering if you solved this proble. i am having the same issue

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [May 26, 2009, 3:58pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/12 "2009-05-26T15:58:26Z")

</div>

mr\_robot wrote:

> hi just wondering if you solved this proble. i am having the same issue

'kay; same problem (thumbnails not being generated);  
happened just by moving from a model to another (from  
app/models/asset.rb to app/models/item.rb).  
columns are just fine; but still getting the same problem.

I just don’t know what’s the problem, is there any model caching or  
something like that in there ? weirdâ€¦

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [June 26, 2009, 5:10pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/13 "2009-06-26T17:10:32Z")

</div>

this is a great thread and helped me get my hands around debugging this  
thing.

some more tips –

1 here’s another thing to look for with respect to parent\_id: if  
you’re using uuid (string) instead of id (integer) make sure your  
parent\_id is also a string and not an integer, otherwise you won’t get  
thumbnails

2 if you’re a windows user, ruby is faster than windows so for your  
create and update actions (assuming REST) make sure you stick in a  
sleep(2) to allow windows to catch up to your rails app when you post:

def create  
sleep(2)  
…

def update  
sleep(2)  
…

---

<div class="post-metadata">

**Author:** ![jko170](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jko170](https://www.ruby-forum.com/u/jko170)\
**Post date:** [May 26, 2009, 4:29pm UTC](https://www.ruby-forum.com/t/attachment-fu-thumbnail-not-created/91425/14 "2009-05-26T16:29:51Z")

</div>

aa bb wrote:

> mr\_robot wrote:
> 
> > hi just wondering if you solved this proble. i am having the same issue
> 
> 'kay; same problem (thumbnails not being generated);  
> happened just by moving from a model to another (from  
> app/models/asset.rb to app/models/item.rb).  
> columns are just fine; but still getting the same problem.
> 
> I just don’t know what’s the problem, is there any model caching or  
> something like that in there ? weirdâ€¦

'aightâ€¦ the fuc\*$$â‚¬Â¨!!- column parent\_id has to be NULLâ€¦ and not at  
default 0
