Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use Sinatra, Datamapper, DM-Paperclip and S3?
    primarykey
    data
    text
    <p><em><strong>Update:</strong> I've switched to CarrierWave (finally got it to work), so although I still appreciate answers to this question I won't be able to try if they actually work since I've completely removed DM-Paperclip</em> from my code.</p> <hr> <p>Hi there,</p> <p>I'm developing a Sinatra-webapp using DataMapper and are now looking to add some upload-functionality with S3 as storage. I've tried <a href="https://github.com/jnicklas/carrierwave" rel="nofollow">CarrierWave</a>, but I couldn't get that to work so now I'm trying dm-paperclip. This is what I have right now:</p> <p>Model:</p> <pre><code>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 =&gt; :s3, :s3_credentials =&gt; { :access_key_id =&gt; 'my-access-key-id', :secret_access_key =&gt; 'my-secret_access-key', :bucket =&gt; 'my-bucket' }, :styles =&gt; { :medium =&gt; "300x300&gt;", :thumb =&gt; "100x100&gt;" } end </code></pre> <p>Controller:</p> <pre><code>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 =&gt; e puts "Error saving article: #{e.to_s} validation: #{@article.errors.values.join(', ')}" rescue StandardError =&gt; e puts "Got an error trying to save the article #{e.to_s}" end redirect '/articles' end </code></pre> <p>Yet when I create a new article it doesn't save anything to my S3 bucket and I don't get any errors either.</p> <p>Any ideas what I'm doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload