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

Delayed paperclip defaults #88

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,26 @@ styles as arguments anymore. It will delegate to DelayedPaperclip and reprocess
@user.avatar.reprocess_without_delay!(:medium)
</code></pre>

h2. Defaults

Global defaults for all delayed_paperclip instances in your app can be defined by changing the
DelayedPaperclip.options Hash, this can be useful for setting a default 'processing image,' so you
won't have to define it in every process_in_background definition.

If you're using Rails you can define a Hash with default options in config/application.rb or in any
of the config/environments/*.rb files on config.delayed_paperclip_defaults, these will get merged into
DelayedPaperclip.options as your Rails app boots. An example:

module YourApp
class Application < Rails::Application
# Other code...

config.delayed_paperclip_defaults = {
:url_with_processing => true,
:processing_image_url => 'custom_processing.png'
}
end
end

h2. What if I'm not using images?

Expand Down
2 changes: 1 addition & 1 deletion lib/delayed_paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def process_in_background(name, options = {})
:priority => 0,
:only_process => only_process_default,
:url_with_processing => DelayedPaperclip.options[:url_with_processing],
:processing_image_url => options[:processing_image_url],
:processing_image_url => DelayedPaperclip.options[:processing_image_url],
:queue => nil
}.each do |option, default|

Expand Down
6 changes: 5 additions & 1 deletion lib/delayed_paperclip/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ module DelayedPaperclip

# On initialzation, include DelayedPaperclip
class Railtie < Rails::Railtie
initializer 'delayed_paperclip.insert_into_active_record' do
initializer 'delayed_paperclip.insert_into_active_record' do |app|
ActiveSupport.on_load :active_record do
DelayedPaperclip::Railtie.insert
end

if app.config.respond_to?(:delayed_paperclip_defaults)
DelayedPaperclip.options.merge!(app.config.delayed_paperclip_defaults)
end
end
end
end
Expand Down