问题
I am trying to get paperclip to work with S3 and my views are throwing an error:
cannot load such file -- aws-sdk (You may need to install the aws-sdk gem)
I have rails configured this way:
Gemfile
...
gem "paperclip", "~> 3.0"
gem 'aws-sdk'
...
Model
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: #
with "#" denoting the correct id/key
Template:
<%= 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 %>
....
Please let me know if you see anything incorrect that may help. Thanks
回答1:
Try restarting your server. I had the same error and that worked for me.
回答2:
Are you also including the s3 gem?
gem 'aws-s3'
回答3:
The error is now resolved after installing imageMagick: https://github.com/thoughtbot/paperclip/blob/master/README.md
And placing:
Paperclip.options[:command_path] = "/usr/local/bin/"
In config/environments/development.rb, which lets paperclip know where to look for imageMagick
来源:https://stackoverflow.com/questions/10369579/error-after-installing-aws-sdk