Update: I switched to CarrierWave (finally got it to work), so although I still appreciate the answers to this question, I canβt try if they really work, ve completely removed DM-Paperclip from my code.
Hi,
I am developing Sinatra-webapp using DataMapper and now I want to add some boot functions from S3 as storage. I tried CarrierWave , but I could not get this to work, so now I am trying to execute dm-paperclip. This is what I have right now:
Model:
class Article
include DataMapper::Resource
include Paperclip::Resource
property :id, Serial
property :created_at, DateTime
property :updated_at, DateTime
property :title, String
property :body, Text
has_attached_file :screenshot,
:storage => :s3,
:s3_credentials => {
:access_key_id => 'my-access-key-id',
:secret_access_key => 'my-secret_access-key',
:bucket => 'my-bucket'
},
:styles => {
:medium => "300x300>",
:thumb => "100x100>"
}
end
Controller:
post '/articles/create' do
@article = Article.new
@article.title = params[:title]
@article.body = params[:body]
@article.screenshot = params[:screenshot]
begin
@article.save
rescue DataMapper::SaveFailureError => e
puts "Error saving article: #{e.to_s} validation: #{@article.errors.values.join(', ')}"
rescue StandardError => e
puts "Got an error trying to save the article #{e.to_s}"
end
redirect '/articles'
end
But when I create a new article, it does not save anything in my S3 statement, and I also get no errors.
Any ideas what I'm doing wrong?