У меня проблема с импортом Cloudinary :: CarrierWave в мое приложение Rails. У меня есть эта ошибка в строке с импортом (включая Cloudinary :: CarrierWave, если Rails.env.test?)
undefined метод `cache_storage 'для AvatarUploader: Class Вы имели в виду? cache_dir
Вы видите какие-нибудь проблемы? Все перепробовал: (
Загрузчик моего аватара:
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
include Cloudinary::CarrierWave unless Rails.env.test?
process :convert => 'png'
process :tags => ['post_picture']
process :custom_crop
# Choose what kind of storage to use for this uploader:
#storage :postgresql_table
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
#def store_dir
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
#end
def default_url(*args)
ActionController::Base.helpers.asset_path("default-avatar.png")
end
version :thumb do
process :eager => true
#process crop: :avatar
resize_to_limit(300,300)
cloudinary_transformation :quality => 80, :gravity => :face
end
version :mini do
process :eager => true
#process crop: :avatar
resize_to_limit(40,40)
cloudinary_transformation :quality => 80, :gravity => :face
end
def public_id
return model.full_name
end
def custom_crop
return :x => model.crop_x, :y => model.crop_y,
:width => model.crop_width, :height => model.crop_height, :crop => :crop
end
end
Мой user.rb
mount_uploader :avatar, AvatarUploader
crop_uploaded :avatar
в приложении. js
//= require cloudinary/jquery.cloudinary
в приложении. html .haml
= cloudinary_js_config
в environment.rb
require 'carrierwave/orm/activerecord'
cloudinary.yml
#CLOUDINARY_URL: "myurl"
development:
cloud_name: mycloud
api_key: 'xxxx'
api_secret: xxxx
# enhance_image_tag: true
# static_file_support: false
production:
cloud_name: mycloud
api_key: 'xxxx'
api_secret: xxxx
# enhance_image_tag: true
# static_file_support: true
test:
cloud_name: mycloud
api_key: 'xxxx'
api_secret: xxxx
# enhance_image_tag: true
# static_file_support: false
Gemfile
gem 'carrierwave', '0.10.0'
#gem "carrierwave-postgresql-table"
gem 'carrierwave-crop', '0.1.2'
gem 'cloudinary
'