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

Commit a1e169b

Browse files
author
Scott Carleton
committed
Merge pull request #88 from kevinmtrowbridge/delayed_paperclip_defaults
Delayed paperclip defaults
2 parents 499037e + 10e6757 commit a1e169b

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.textile

+20
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ styles as arguments anymore. It will delegate to DelayedPaperclip and reprocess
142142
@user.avatar.reprocess_without_delay!(:medium)
143143
</code></pre>
144144

145+
h2. Defaults
146+
147+
Global defaults for all delayed_paperclip instances in your app can be defined by changing the
148+
DelayedPaperclip.options Hash, this can be useful for setting a default 'processing image,' so you
149+
won't have to define it in every process_in_background definition.
150+
151+
If you're using Rails you can define a Hash with default options in config/application.rb or in any
152+
of the config/environments/*.rb files on config.delayed_paperclip_defaults, these will get merged into
153+
DelayedPaperclip.options as your Rails app boots. An example:
154+
155+
module YourApp
156+
class Application < Rails::Application
157+
# Other code...
158+
159+
config.delayed_paperclip_defaults = {
160+
:url_with_processing => true,
161+
:processing_image_url => 'custom_processing.png'
162+
}
163+
end
164+
end
145165

146166
h2. What if I'm not using images?
147167

lib/delayed_paperclip.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def process_in_background(name, options = {})
5757
:priority => 0,
5858
:only_process => only_process_default,
5959
:url_with_processing => DelayedPaperclip.options[:url_with_processing],
60-
:processing_image_url => options[:processing_image_url],
60+
:processing_image_url => DelayedPaperclip.options[:processing_image_url],
6161
:queue => nil
6262
}.each do |option, default|
6363

lib/delayed_paperclip/railtie.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ module DelayedPaperclip
77

88
# On initialzation, include DelayedPaperclip
99
class Railtie < Rails::Railtie
10-
initializer 'delayed_paperclip.insert_into_active_record' do
10+
initializer 'delayed_paperclip.insert_into_active_record' do |app|
1111
ActiveSupport.on_load :active_record do
1212
DelayedPaperclip::Railtie.insert
1313
end
14+
15+
if app.config.respond_to?(:delayed_paperclip_defaults)
16+
DelayedPaperclip.options.merge!(app.config.delayed_paperclip_defaults)
17+
end
1418
end
1519
end
1620
end

0 commit comments

Comments
 (0)