Media problem

This question was asked, but there was no answer ... I have the same problem.

I use a carrier to download files, everything works fine until I wanted to create a thumbs up.

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

The file of my avatar_uploader.rb is as follows:

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 do not turn on (: the thumb), I see full images ... but when I turn on (: 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 see that the tmp directory was created, but the images did not change ... I have imagemagick and rmagick ...

thanks

+6
source share
4 answers

I think you might want to recreate the versions, as you can create a thumb size for some images after you have downloaded some other files.

 image.avatar.url(:thumb) 

the syntax above is fine

To recreate the versions, try running

 image.avatar.recreate_versions! 

on all avatars that may be missing.

+8
source

Try one of these syntaxes:

 image.avatar.thumb.url # or image.avatar.url(:thumb) 
+4
source

I suggest using

 include CarrierWave::MiniMagick 

instead

 include CarrierWave::RMagick 

Because it may happen that you do not have all the dependent RMagick libraries. The Thumb version is created using RMagick or MiniMagick. Problem with your RMagick.

+1
source

Have you tried Dragon Pearls? I know that I do not solve your problem. But after using it a couple of times, I think it's better than a carrier wave when it comes to images. Dragonfly Gem does not create many images, just resizes one image to the size you specify, compared to the carrier, which creates a lot of thumbs.

-1
source

Source: https://habr.com/ru/post/915463/


All Articles