views/articles/_post.html.erb
<%= render partial: "shared/info" %>
views/stories/_post.html.erb
<%= render partial: "shared/info" %>
irb(main):001:0> Delayed::Job.find("1").last_error | |
Paperclip::Errors::InfiniteInterpolationError | |
/usr/home/myapp/vendor/bundle/ruby/2.2.0/gems/paperclip-4.2.1/lib/paperclip/interpolations.rb:53:in `url' | |
/usr/home/myapp/vendor/bundle/ruby/2.2.0/gems/paperclip-4.2.1/lib/paperclip/interpolations.rb:34:in `block (2 levels) in interpolate' | |
/usr/home/myapp/vendor/bundle/ruby/2.2.0/gems/paperclip-4.2.1/lib/paperclip/interpolations.rb:33:in `gsub' | |
/usr/home/myapp/vendor/bundle/ruby/2.2.0/gems/paperclip-4.2.1/lib/paperclip/interpolations.rb:33:in `block in interpolate' | |
/usr/home/myapp/vendor/bundle/ruby/2.2.0/gems/paperclip-4.2.1/lib/paperclip/interpolations.rb:32:in `each' | |
/usr/home/myapp/vendor/bundle/ruby/2.2.0/gems/paperclip-4.2.1/lib/paperclip/interpolations.rb:32:in `inject' | |
/usr/home/myapp/vendor/bundle/ruby/2.2.0/gems/paperclip-4.2.1/lib/paperclip/interpolations.rb:32:in `interpolate' |
The way DelayedJob works is, it serializes the model, sticks it into the db … till it can be processed. Then it re-marshals it … but this process is fragile.
For example, this bit in the
is_animated_gif?
method:attachment.queued_for_write[:original]
… that “queued_for_write” … Paperclip stores the uploaded image in a Tmpfile until it gets uploaded to S3. This is not something that could be serialized. The Tmpfile is probably deleted before the DelayedJob runs. Also, I remember during one Paperclip upgrade, they broke that method … I don’t think it works the same way in newer versions.
Started POST "/default/topics" for ::ffff at 2015-04-05 14:05:33 +0000
Processing by Forem::TopicsController#create as HTML
Parameters: {"utf8"=>"�~\~S", "authenticity_token"=>"+6Ma4fmBeexCEFsP9z8b5Af5vJQKarMssAxFdIHMHGEkRcP09T/zgmlVAM4Trb2iHWkHVFGFrHBqO3E8GGAzJw==", "topic
"=>{"subject"=>"sfgfgsfg", "posts_attributes"=>{"0"=>{"text"=>"sfhsg", "photos_attributes"=>{"0"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile:0x
00000004502798 @tempfile=#<File:/tmp/RackMultipart20150405-50-183sbay.gif>, @original_filename="test.gif", @content_type="image/gif", @headers="Content-
Disposition: form-data; name=\"topic[posts_attributes][0][photos_attributes][0][attachment]\"; filename=\"test.gif\"\r\nContent-Type: imag
attachment_is_animated
in the db to true. But, because this job needs to go into the background (DelayedJob), the temp file is probably gone by the time it's needed, which is most likely what's causing the InfiniteInterpolationError
.Live app which you can run on the fly: http://runnable.com/VXMNrsiY_6Fd-YRn/paperclip-delayedjob-infiniteinterpolationerror (remember to run bin/delayed_job start
before hitting the big green Run button)
Live app with instructions: http://runnable.com/VR3jBtJKSwh21EKs/paperclip-av-transcoder
LoadError in Forem::TopicsController#create
cannot load such file -- /root/rails-repo/lib/paperclip_processors/qtfaststart.rb
Extracted source (around line #274):
Live app: http://runnable.com/VEEnRTEK-igg4XGD/forem-with-paperclip-for-ruby-on-rails
app/views/forem/posts/_post.html.erb
<% for photo in post.photos %>
<%#= image_tag photo.attachment.url(:medium) %>
Straight forward fetching products from the affiliate API takes up to 8 seconds which is intolerable.
Demo app: https://github.com/dt1973/ajax-affiliates
How to set up the callback?
Check for new posts every 5 seconds and add them to the page.
Demo app: https://github.com/dt1973/jp-test
application.js