我正在创建一个rails插件rails new plugin my_plugin --mountable
这是相当多的工作要弄清楚,但它应该使用carrierwave将文件上传到S3,但它说好的但没有上传任何东西
Carrierwave 用于生成上传器,rails g uploader photo
文件如下所示
# my_engine/app/uploaders/my_engine/photo_uploader.rb
# encoding: utf-8
module my_engine
class PhotoUploader < CarrierWave::Uploader::Base
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# 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
end
end
该模型有一个坐骑:照片,PhotoUploader
module PdfGeneratorEngine
class Assemble < ActiveRecord::Base
attr_accessible :color, :photo, :qr_code_url, :text
mount_uploader :photo, PhotoUploader
end
end
我的 CarrierWave 配置文件是这个
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'MY_ACCES_KEY',
:aws_secret_access_key => 'MY_SECRET_KEY',
:provider => 'AWS',
:region => 'eu-west-1'
}
config.fog_directory = 'my.bucket.com'
config.fog_host = 'https://s3-eu-west-1.amazonaws.com/my.bucket.com'
config.storage = :fog
config.s3_use_ssl = true
config.fog_public = true
end
所以首先它开始对fog_host尖叫,如果它是asset_host就可以了
接下来它的问题在于 s3_use_ssl,而它是 CarrierWave 的 github 上的一个合并问题。但是主机已经被定义为 https:// 所以我不明白为什么该行是必要的。
之后它说“好的,它完成了”,当我尝试(使用守护程序)检查文件时,那里什么都没有。
我错过了什么?还是 CarrierWave 和 Rails 可安装引擎存在问题?