Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

carrierwave thumb issue

This question was asked, but no answer given...I'm having the same issue.

I'm using carrierwave for uploading files everything works great until i wanted to create thumbs

images are saved in a tmp direct, but kept at the same size...

My avatar_uploader.rb file looks like this:

class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
def store_dir
   "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
  process :resize_to_limit => [200, 200]
end

My view has the following:

<% for image in @posts %>
<%= image_tag image.avatar_url(:thumb) if image.avatar? %>
<%= image.title %>
<% end %>

When I don't include (:thumb), I see the full images...but when I do include the (:thumb), I get the following error:

Version thumb doesn't exist!

below is my model setup

class Post < ActiveRecord::Base
  attr_accessible :comments, :frame, :title, :twitter, :avatar
  belongs_to :user
  mount_uploader :avatar, AvatarUploader
end

I can see that a tmp directory was created, but images not resized...I have imagemagick and rmagick installed...

Thank you

like image 270
user749798 Avatar asked May 11 '12 02:05

user749798


2 Answers

I think you might want to recreate versions since you might have create thumb size for some images after you uploaded some other files.

image.avatar.url(:thumb)

above syntax is fine

To recreate versions try running

image.avatar.recreate_versions!

on all avatars you might be missing.

like image 198
m4risU Avatar answered Sep 22 '22 02:09

m4risU


Try one of these syntaxes:

image.avatar.thumb.url
# or
image.avatar.url(:thumb)
like image 39
Alex Marchant Avatar answered Sep 19 '22 02:09

Alex Marchant