Forum: Ruby on Rails attachment_fu thumbnail not created

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-04-08 22:55
(Received via mailing list)
I followed the instructions on Mike Clark'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
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-04-09 07:13
(Received via mailing list)
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?
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-04-09 17:55
(Received via mailing list)
Anyone know why the thumbnails are not being created while everything
else is working fine?
72ee7b478a235f646c3495f03ebbe676?d=identicon&s=25 Andrew Stewart (Guest)
on 2007-04-13 13:18
(Received via mailing list)
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/br...
3c86abb8daa12cc6/079b85c99b22be2f

Regards,
Andy Stewart
63bae00378a3ccca653aac7660784773?d=identicon&s=25 isaac (Guest)
on 2007-04-14 02:08
(Received via mailing list)
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.
807e34b31d5463a9ac05d41458a9e537?d=identicon&s=25 Al Evans (al-evans)
on 2007-04-14 17:14
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
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-04-15 20:24
(Received via mailing list)
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.
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-04-15 21:00
(Received via mailing list)
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
34aad1d43c076fae243141ba736114b0?d=identicon&s=25 Guy Davis (Guest)
on 2007-04-16 00:17
(Received via mailing list)
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

He doesn't mention that parent_id is required however.

Guy
1df9fc8ddf084661265bbae74a8d0b43?d=identicon&s=25 jko170 (Guest)
on 2007-04-16 08:38
(Received via mailing list)
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?
452944b6d34db40a01defafa1f9acd2b?d=identicon&s=25 mr_robot (Guest)
on 2007-04-26 16:02
(Received via mailing list)
hi just wondering if you solved this proble. i am having the same issue
561a3a55352fe6a5343e541a6894b541?d=identicon&s=25 aa bb (bbnnt)
on 2009-05-26 15:58
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…
561a3a55352fe6a5343e541a6894b541?d=identicon&s=25 aa bb (bbnnt)
on 2009-05-26 16:29
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
Baef607ee7cdc260681d77d7ef473909?d=identicon&s=25 John Clancy (lastps)
on 2009-06-26 17:10
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)
  ..
This topic is locked and can not be replied to.