我一直在寻找类似主题的解决方案,但是不知道为什么无法使其工作。 这是我的应用程序日志。
Command :: identify -format %wx%h '/tmp/0120121215-31657-19vihny.jpg[0]'
Command :: convert '/tmp/0120121215-31657-19vihny.jpg[0]' -auto-orient -resize "32x32!" - background white -flatten +matte '/tmp/0120121215-31657-19vihny20121215-31657-58mm3a.png'
Command :: identify -format %wx%h '/tmp/0120121215-31657-19vihny.jpg[0]'
Command :: convert '/tmp/0120121215-31657-19vihny.jpg[0]' -auto-orient -resize "320x320!" -background white -flatten +matte '/tmp/0120121215-31657-19vihny20121215-31657-1n3fgl2.png'
[paperclip] Saving attachments.
[paperclip] saving images/:User/50cc0cfb0feea807f6000004/original.jpg
[paperclip] saving images/:User/50cc0cfb0feea807f6000004/small.png
[paperclip] saving images/:User/50cc0cfb0feea807f6000004/medium.png
Started POST "/photos" for 127.0.0.1 at 2012-12-15 12:39:07 +0700
Processing by PhotosController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"SSjceuOzRNQfJyUCki86mNBfuHsK0bh5qQmX4pBi7uk=", "photo"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0xb27e0164 @original_filename="01.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"photo[image]\"; filename=\"01.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20121215-31657-9oqjbm>>, "description"=>"This is decscription"}, "commit"=>"Create Photo"}
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.7489ms)
MOPED: 127.0.0.1:27017 INSERT database=image12345_development collection=photos documents=[{"_id"=>"50cc0cfb0feea807f6000004", "image_file_name"=>"01.jpg", "image_content_type"=>"image/jpeg", "image_file_size"=>368812, "image_updated_at"=>2012-12-15 05:39:07 UTC, "description"=>"This is decscription"}] flags=[] (0.2658ms)
[AWS S3 200 8.971826 0 retries] put_object(:acl=>:public_read,:bucket_name=>"image12345",:content_length=>368812,:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: 01.jpg,:key=>"images/:User/50cc0cfb0feea807f6000004/original.jpg")
[AWS S3 200 0.214209 0 retries] put_object(:acl=>:public_read,:bucket_name=>"image12345",:content_length=>2763,:content_type=>"image/png",:data=>Paperclip::FileAdapter: 0120121215-31657-19vihny20121215-31657-58mm3a.png,:key=>"images/:User/50cc0cfb0feea807f6000004/small.png")
[AWS S3 200 3.498196 0 retries] put_object(:acl=>:public_read,:bucket_name=>"image12345",:content_length=>142791,:content_type=>"image/png",:data=>Paperclip::FileAdapter: 0120121215-31657-19vihny20121215-31657-1n3fgl2.png,:key=>"images/:User/50cc0cfb0feea807f6000004/medium.png")
Redirected to http://localhost:3000/photos/50cc0cfb0feea807f6000004
Completed 302 Found in 12992ms
我使用 devise 管理用户。
在我的 gem 文件中,有以下内容:
gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'paperclip'
gem "aws-sdk"
在我的models/photo.rb文件中。
has_mongoid_attached_file :image,
:path => ':attachment/:User/:id/:style.:extension',
:storage => :s3,
:s3_credentials => File.join(Rails.root, 'config', 's3.yml'), #s3.yml contain credentials
:styles => {
:small => ['32x32!', :png],
:medium => ['320x320!', :png, :jpg],
},
:convert_options => { :all => '-background white -flatten +matte' }
attr_accessible :image, :description
在我的表单中
<%= form_for(@photo , :html => {:multipart => true} ) do |f| %>
<div class="field">
<%= f.label :image %><br />
<%= f.file_field :image %>
</div>
<% end %>
我已经尝试了很多解决方案,比如添加form_helper :multipart。在我的之前的应用程序中,这个模型和gem都能正常工作,我也确信我的凭证是正确的。它只告诉我更新成功,但没有上传图片。 我应该在哪里寻找这个问题的错误?或者有什么工具可以使用?我真的被卡住了,想要解决它,而不是创建新的应用程序并祈求好运。