carrierwave-qiniu configuration error
Closed this issue · 8 comments
LaoLiulaoliu commented
.../config/initializers/carrierwave.rb:8:in `block in <top (required)>': undefined method `qiniu_bucket_private=' for CarrierWave::Uploader::Base:Class (NoMethodError)
from /Users/bishop/.rvm/gems/ruby-2.1.4/gems/carrierwave-0.10.0/lib/carrierwave/uploader/configuration.rb:118:in `configure'
from /Users/bishop/.rvm/gems/ruby-2.1.4/gems/carrierwave-0.10.0/lib/carrierwave.rb:14:in `configure'
from /Users/bishop/project/medical/ourdrs/config/initializers/carrierwave.rb:2:in `<top (required)>'
from /Users/bishop/.rvm/gems/ruby-2.1.4/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
配置我照抄:
config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.storage = :qiniu
config.qiniu_access_key = "your qiniu access_key"
config.qiniu_secret_key = 'your qiniu secret_key'
config.qiniu_bucket = "carrierwave-qiniu-example"
config.qiniu_bucket_domain = "carrierwave-qiniu-example.aspxboy.com"
config.qiniu_bucket_private= true #default is false
config.qiniu_block_size = 4*1024*1024
config.qiniu_protocol = "http"
end
Gemfile:
gem 'carrierwave'
gem 'carrierwave-qiniu'
gem 'qiniu-rs'
huobazi commented
@LaoLiulaoliu 你的 Uploader 怎么定义的?
victorteokw commented
同有这个问题。
如果注释掉qiniu_bucket_private和qiniu_protocol的调用,就会抛如下错误。
uploader 几乎没有定义
TypeError - class or module required for rescue clause:
qiniu-rs (1.1.0) lib/qiniu/rs/auth.rb:64:in `rescue in request'
qiniu-rs (1.1.0) lib/qiniu/rs/auth.rb:62:in `request'
class AttachmentUploader < CarrierWave::Uploader::Base
def filename
"avatar.#{file.extension}" if original_filename.present?
end
def store_dir
"uploads/#{model.class.to_s.underscore.pluralize}/#{mounted_as}/#{model.id}"
end
end
huobazi commented
qiniu-rs
这个 gem 七牛 官方已经停止维护了,不要用了。 carrierwave-qiniu
会自动引入 qiniu
这个 gem
更多请参考如下两个连接:
victorteokw commented
@huobazi
问题已解决 多谢😊
victorteokw commented
可以写在README.md中,不然的话carrierwave-qiniu
抛错可能会提到qiniu-rs
,会误导安装qiniu-rs
。
LaoLiulaoliu commented
谢谢,我放弃carrierwave,直接用ruby_sdk 了
Lupeipei commented
我这边遇到的同样的问题,看前辈们的讨论,我试着把gem 'qiniu-rs'删除了,可是部署的时候,终端报错,显示Bundler::GemRequireError: There was an error while trying to load the gem 'carrierwave-qiniu', Gem Load Error is: You dot't have the 'qiniu-rs' gem installed。