我有以下 CarrierWave 初始化程序,它在我的 Heroku/MONGOHQ/GridFS env 上运行良好:
CarrierWave.configure do |config|
config.storage = :grid_fs
uri = URI.parse(ENV['MONGOHQ_URL'])
config.grid_fs_database = File.basename(uri.path)
config.grid_fs_host = uri.host unless uri.host.blank?
config.grid_fs_port = uri.port unless uri.port.blank?
config.grid_fs_username = uri.user unless uri.user.blank?
config.grid_fs_password = uri.password unless uri.password.blank?
config.grid_fs_access_url = '/gridfs'
config.cache_dir = "uploads"
config.root = Rails.root.join('tmp')
end
但是,当我尝试在本地(在开发中)运行代码时,出现以下错误:
`split': bad URI(is not URI?): (URI::InvalidURIError)
这是完整的堆栈: http: //pastie.org/1630069我试图在初始化程序顶部添加 require 'uri/generic' 但不起作用。
有人知道方法吗?在此先感谢卢卡