2

次のファイルアップローダーがあります

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

また、carrier_wave.rb 初期化ファイルの次の構成:

CarrierWave.configure do |config|
config.enable_processing = true
    #config.permissions = 0666
    #config.directory_permissions = 0777
    config.storage = :file
end

画像は適切にアップロードされましたが、サムネイルは作成されず、エラーは発生しませんでした。お知らせ下さい。

4

2 に答える 2