Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

[docs] Adding a section about 'url_with_processing.' #87

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,35 @@ being processed.

</code></pre>

h4. Have processing? status available, but construct image URLs as if delayed_paperclip wasn't present

If you define the #{attachment_name}_processing column, but set the url_with_processing option to false,
this opens up other options (other than modifying the url that paperclip returns) for giving feedback to
the user while the image is processing. This is useful for advanced situations, for example when dealing
with caching systems.

Note especially the method .processing? which passes through the value of the boolean created via migration.

<pre><code>

class User < ActiveRecord::Base
has_attached_file :avatar

process_in_background :avatar, :url_with_processing => false
end

@user = User.new(:avatar => File.new(...))
@user.save
@user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
@user.avatar.processing? #=> true
Delayed::Worker.new.work_off

@user.reload
@user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
@user.avatar.processing? #=> false

</code></pre>

h4. Only process certain styles

This is useful if you don't want the background job to reprocess all styles.
Expand Down