安装aws-sdk后出错

时间:2012-04-29 04:00:41

标签: amazon-s3 paperclip

我正在尝试使用回形针来处理S3并且我的观点引发了错误:

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

我通过这种方式配置了导轨:

的Gemfile

...
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 %>
....

如果您发现任何可能有帮助的错误,请告知我们。感谢

3 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:2)

你还包括s3宝石吗?

gem 'aws-s3'

答案 2 :(得分:0)

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

放置:

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

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