2

我正在尝试让回形针与 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 %>
....

如果您发现任何可能有帮助的不正确之处,请告诉我。谢谢

4

3 回答 3

3

尝试重新启动您的服务器。我有同样的错误,这对我有用。

于 2012-06-28T16:40:35.570 回答
2

您是否还包括 s3 gem?

gem 'aws-s3'
于 2012-05-09T15:24:58.280 回答
0

安装 imageMagick 后,该错误现已解决:https ://github.com/thoughtbot/paperclip/blob/master/README.md

并放置:

  Paperclip.options[:command_path] = "/usr/local/bin/"

在 config/environments/development.rb 中,它让回形针知道在哪里寻找 imageMagick

于 2012-04-29T14:10:18.943 回答