简体   繁体   English

Rails Paperclip和AWS s3集成错误“未初始化的常量Paperclip :: Storage :: S3 :: Aws”

[英]Rails Paperclip and aws s3 integration error “uninitialized constant Paperclip::Storage::S3::Aws”

I have gone through different posts but got no help, I am trying to upload my images to Amazon S3 I double checked my asw credentials they all are correct, here are the required files please help 我经历了不同的帖子,但没有帮助,我试图将图像上传到Amazon S3,我再次检查了我的asw凭证,它们都正确,这是必填文件,请帮助

Gemfile 宝石文件

gem 'aws-sdk', '< 2.0'
gem 'devise'
gem "paperclip", "~> 5.0.0.beta1"
gem 'bootstrap-sass', '~> 3.3.6'
gem 'bootstrap-material-design'
gem 'nested_scaffold'  

config/environments/development.rb config / environments / development.rb

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  config.action_mailer.delivery_method = :smtp

  config.paperclip_defaults = {
  storage: :s3,
  s3_credentials: {
    bucket: "bucketName",
    access_key_id: "xoxoxo",
    secret_access_key: "secret_key"

  }
}

config/initializers/paperclip.rb config / initializers / paperclip.rb

# config/initializers/paperclip.rb
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3-us-west-2.amazonaws.com'

And while uploading Iam still getting the error 而且在上传Iam时仍然出现错误

NameError in CorporateTrainersController#create uninitialized constant Paperclip::Storage::S3::Aws CorporateTrainersController#Name中的NameError创建未初始化的常量Paperclip :: Storage :: S3 :: Aws

Extracted source (around line #29):          
  # POST /corporate_trainers.json
  def create
    @corporate_trainer = CorporateTrainer.new(corporate_trainer_params)

    respond_to do |format|
      if @corporate_trainer.save

just drop your gemfile version. 只需删除您的gemfile版本即可。 may be it help you. 可能对您有帮助。

    gem "paperclip",'4.3.6' #last stable version

    gem 'aws-sdk', '< 2.0'


than bundle install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM