Có một really nice article Tôi đã sử dụng khi được lần đầu tiên thiết lập AA+s3+Paperclip
.
Nó có giải thích tốt + example app on Github, vì vậy bạn có thể kiểm tra trực tiếp.
Trong AA dạng sẽ giống như thế này:
form multipart: true do |f|
# f.semantic_errors *f.object.errors.keys
f.inputs do
f.input :image_name #or whatever field is called
end
f.has_many :attachments do |a|
if a.object.persisted?
link_to image_tag(a.object.encoded_url, class: 'image-preview'), a.object.encoded_url, target: "_blank"
else
a.inputs do
a.s3_file_field(:attachment, as: :file, class: 'js-s3_file_field')
end +
a.inputs do
a.input(:s3_url, as: :hidden, input_html: { class: "s3_url" })
end
end
end
f.actions
end
Nguồn
2014-12-26 14:46:59
http://blog.littleblimp.com/post/53942611764/direct-uploads-to-s3-with-rails-paperclip-and –