【发布时间】:2012-12-06 15:39:38
【问题描述】:
我正在使用 rails new plugin my_plugin --mountable 创建一个 Rails 插件
这是一项相当多的工作要弄清楚,但它应该使用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
模型有一个坐骑:photo, 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 可安装引擎存在问题?
【问题讨论】:
标签: ruby-on-rails amazon-s3 carrierwave rails-engines fog