Issue with Paperclip/S3 in Rails 3.2.5 “cannot load such file — aws-sdk”

家住魔仙堡 提交于 2020-01-02 19:29:06

问题


Image Uploading was working fine, but when I tried switching it to S3, it started throwing an error. I get the following error when I try to create a new image upload:

cannot load such file -- aws-sdk (You may need to install the aws-sdk gem)

Relevant gems:

gem 'rails', '3.2.5'
gem 'paperclip'
gem 'aws-sdk'

config/s3.yml:

development:
    bucket: bucketname
    access_key_id: #
    secret_access_key: #

test:
    bucket: bucketname
    access_key_id: #
    secret_access_key: #

image_upload.rb:

  has_attached_file :image,
    :styles => {
      :normal => "1680x6000",
      :result => "560x3000",
      :thumb => "140x500" },
    :path => ":attachment/:style/:normalized_file_name.:extension",
    :storage => :s3,
    :s3_credentials => "#{Rails.root}/config/s3.yml"

Things I have tried:

  • bundle install
  • Change the version of aws-sdk to 1.3.4
  • gem install aws-sdk
  • Changed the s3_credentials "Rails.root" part to a few different things.

Thank you for the help!!


回答1:


A little embarrassing... I just needed to restart rails server. Can't believe I forgot to do that.




回答2:


What happens if you add require 'rubygems' to the top of the file where you are requiring aws-sdk?



来源:https://stackoverflow.com/questions/11236847/issue-with-paperclip-s3-in-rails-3-2-5-cannot-load-such-file-aws-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!