我正在尝试让回形针与 S3 一起使用,但我的 View 抛出错误:
cannot load such file -- aws-sdk (You may need to install the aws-sdk gem)
我以这种方式配置了 Rails:
gem 文件
...
gem "paperclip", "~> 3.0"
gem 'aws-sdk'
...
型号
user.rb
...
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" },
:storage => :s3,
:bucket => ENV['lumeo-dev'],
:s3_credentials => "lumeot/config/aws.yml",
:path => "/:style/:id/:filename"
...
config/aws.yml
development:
bucket: lumeo-dev
access_key_id: #
secret_access_key: #
test:
bucket: lumeo-test
access_key_id: #
secret_access_key: #
production:
bucket: lumeo-pro
access_key_id: #
secret_access_key: #
其中“#”表示正确的 ID/ key
模板:
<%= simple_form_for(resource, :as => resource_name, :url =>
registration_path(resource_name), :html => { :method => :put, :multipart => true }) do |f| %>
<%= f.error_notification %>
<div class="inputs">
<p>
<% if current_user.avatar.present? %>
Change Photo
<%= image_tag @user.avatar.url(:thumb) %>
<% else %>
Upload New Photo
<%= gravatar_for current_user %>
<% end %>
</p>
<%= f.file_field :avatar %>
....
如果您发现任何可能有帮助的错误内容,请告诉我。谢谢
最佳答案
尝试重新启动您的服务器。我遇到了同样的错误,这对我有用。
关于amazon-s3 - 安装aws-sdk后出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10369579/