我正在尝试让回形针与 S3 一起使用,但我的观点抛出了一个错误:
cannot load such file -- aws-sdk (You may need to install the aws-sdk 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"
...
配置/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 %>
....
如果您发现任何可能有帮助的不正确之处,请告诉我。谢谢