delayed_paperclip icon indicating copy to clipboard operation
delayed_paperclip copied to clipboard

Custom styles of paperclip are not rendered in process_in_background.

Open rorlab opened this issue 12 years ago • 12 comments

I faced a problem using delayed_paperclip gem. I had already set up according to the direction on manual. When I insert the code "process_in_background" on the relevant model, custom styles of paperclip aren't generated but the original file is well uploaded to server. I confirmed that all styles of paperclip are well generated without "process_in_background".

My Gemfile is as follows:

gem 'paperclip'
gem 'paperclip-ffmpeg'
gem 'delayed_paperclip', :git => 'git://github.com/tommeier/delayed_paperclip.git', :ref => '98a8b9e0c24d24c94e2c9c39a704c1b07c5c4d6b'
gem 'daemons'
gem 'delayed_job_active_record'
gem 'delayed_job_web'

In Post model,

class Post < ActiveRecord::Base
  attr_accessible :title, :attach
  has_attached_file :attach, :styles => { :medium => "300x300>", :thumb => "100x100>" }
  process_in_background :attach
end

in app/views/posts/_form.html.erb,

<%= form_for(@post) do |f| %>
  <% if @post.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>

      <ul>
      <% @post.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </div>

  <div class="field">
    <%= f.label :attach %>
    <%= f.file_field :attach %>
  </div>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

At this context, when I submit the above form attached with some image file, :medium and :thumb custom styles are not generated at the public/system/attaches directory. But, when I comment out the line of "process_in_background" in post model, all styles are well generated.

So I think that with "process_in_background", convert function of imagemagick doesn't work. Is that right?

Is there any solution about this?

rorlab avatar Aug 28 '12 12:08 rorlab

I can't replicate here. What version of rails are you using?

jrgifford avatar Aug 28 '12 19:08 jrgifford

My development env is as follows:

  • ruby 1.9.3-p194
  • rails 3.2.8

rorlab avatar Aug 29 '12 04:08 rorlab

I think i'm seeing an identical issue, the original image is stored just fine, but none of the styles are saved. Did you make any progress @rorlab ?

Same environment here, no errors shown in log...though i only see ONE aws store line:

[AWS S3 200 0.060147 0 retries] put_object(:acl=>"public-read",:bucket_name=>"ts-imgs-prod",:content_type=>"image/jpeg",:data=>Paperclip::UploadedFileAdapter: img1-2.jpg,:key=>"photos/201/original/img1-2.jpg")

I assume I should be seeing a line like this for EACH of my styles?

mbhnyc avatar Sep 11 '12 23:09 mbhnyc

Are you using S3 / Cloud to store images?

tommeier avatar Sep 11 '12 23:09 tommeier

Was, yeah, but decided to nip it in the bud by jumping over to CW since this isn't maintained actively anymore :(

mbhnyc avatar Sep 12 '12 16:09 mbhnyc

@mbhnyc I'm adopting it - you can find the work in progress I'm doing over here.

jrgifford avatar Sep 13 '12 13:09 jrgifford

Same problem here. The styles are not rendered but the worker keeps saving the instance again and again.

  • ruby 1.9.3-p194
  • rails 1.9.3
  • paperclip 3.3.0
  • paperclip-ffmpeg 0.9.1
  • delayed_paperclip 2.4.5.2

atd avatar Oct 10 '12 12:10 atd

Solution proposed in #67 solved the issue for me!

atd avatar Oct 10 '12 12:10 atd

Thank you very much! I'll try #67.

rorlab avatar Oct 10 '12 13:10 rorlab

@rorlab: Let me know if it works. I'll need to add a test for it, and get the fix released ASAP.

jrgifford avatar Oct 10 '12 17:10 jrgifford

OMG~ My mistake! I replaced the original code of the process_delayed! method with one of #67 and then, it works wonderfully.

New process_delayed! method,

  def process_delayed!
    self.job_is_processing = true
    self.post_processing = true
    reprocess!
    self.job_is_processing = false
  end

in my Gemfile,

gem 'delayed_paperclip', :git => 'git://github.com/tommeier/delayed_paperclip.git', :ref => '98a8b9e0c24d24c94e2c9c39a704c1b07c5c4d6b'

Thank you very much!

rorlab avatar Oct 21 '12 04:10 rorlab

I got the same error, Where should put this function (process_delayed!)?

lobna avatar Jul 25 '13 04:07 lobna