use*_*062 3 ruby-on-rails rmagick carrierwave ruby-on-rails-4
我正在使用carrierwave和rmagick来处理我的图片上传.我现在在image_uploader.eb中添加了一个新版本(smallthumb):
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
def store_dir
"uploads/images"
end
version :thumb do
process :resize_to_fill => [250, 250]
end
version :smallthumb do
process :resize_to_fill => [70, 70]
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
Run Code Online (Sandbox Code Playgroud)
我有一个名为"image"的模型,其中安装了图像上传器:
class Image < ActiveRecord::Base
attr_accessible :date, :description, :name, :size, :image, :article_ids
has_and_belongs_to_many :articles
mount_uploader :image, ImageUploader
end
Run Code Online (Sandbox Code Playgroud)
我已经读过我需要调用recreate_versions !,但是我不明白我需要在哪里调用这个操作以及如何调用.我在公共/上传/图像的实时服务器上有我的图像.如何重新创建所有这些图像的版本(在我的开发机器和实时服务器上),以便我也可以使用图像的小型版本?
| 归档时间: |
|
| 查看次数: |
5064 次 |
| 最近记录: |