Rails CarrierWave版本不是出于某种原因而创建的 [英] Rails CarrierWave versions are not created for some reason
本文介绍了Rails CarrierWave版本不是出于某种原因而创建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下文件上传器
class ItemImageUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
asset_path("fallback/" + [version_name, "image.png"].compact.join('_'))
end
def cache_dir
"uploads/tmp"
end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [80,80]
end
def extension_white_list
%w(jpg jpeg gif png)
end
图片类
class Picture < ActiveRecord::Base
belongs_to :imageable, :polymorphic => true
mount_uploader :image, ItemImageUploader
process_in_background :image
validates_presence_of :image
def copy
Picture.new(:image => self.image)
end
以及car_wave.rb初始化文件中的以下配置:
And the following config in carrier_wave.rb initialization file:
CarrierWave.configure do |config|
config.enable_processing = true
#config.permissions = 0666
#config.directory_permissions = 0777
config.storage = :file
end
图片已正确上传,但未创建缩略图,未发生任何错误。请指教。
Images uploaded properly, but no thumbnails created, no errors occurred. Please advise.
推荐答案
我自己就碰到了这个。正如评论所示,使用 carrierwave_backgrounder
会导致此问题。您可以在文档中看到它:
Just hit my head against this one myself. As the comments suggest, using carrierwave_backgrounder
causes this problem. You can see it in their documentation:
process_in_background - 这会保存原始文件而不进行处理/版本控制。
process_in_background - This stores the original file with no processing/versioning.
无效解决方案,但我想我会验证问题。
Doesn't help with a solution, but I thought I'd verify the problem.
这篇关于Rails CarrierWave版本不是出于某种原因而创建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文