Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom styles of paperclip are not rendered in process_in_background. #70

Open
rorlab opened this issue Aug 28, 2012 · 12 comments
Open

Comments

@rorlab
Copy link

rorlab commented Aug 28, 2012

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?

@jrgifford
Copy link

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

@rorlab
Copy link
Author

rorlab commented Aug 29, 2012

My development env is as follows:

  • ruby 1.9.3-p194
  • rails 3.2.8

@mbhnyc
Copy link

mbhnyc commented Sep 11, 2012

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?

@tommeier
Copy link
Collaborator

Are you using S3 / Cloud to store images?

@mbhnyc
Copy link

mbhnyc commented Sep 12, 2012

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

@jrgifford
Copy link

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

@atd
Copy link

atd commented Oct 10, 2012

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
Copy link

atd commented Oct 10, 2012

Solution proposed in #67 solved the issue for me!

@rorlab
Copy link
Author

rorlab commented Oct 10, 2012

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

@jrgifford
Copy link

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

@rorlab
Copy link
Author

rorlab commented Oct 21, 2012

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!

@lobna
Copy link

lobna commented Jul 25, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants