Commit 7832694f by Jon Yurek

Fixed the rake task.

parent d177c8f8
...@@ -6,8 +6,8 @@ end ...@@ -6,8 +6,8 @@ end
def obtain_attachments def obtain_attachments
name = ENV['ATTACHMENT'] || ENV['attachment'] name = ENV['ATTACHMENT'] || ENV['attachment']
raise "Class #{@klass.name} has no attachments specified" unless @klass.respond_to?(:attachment_names) raise "Class #{@klass.name} has no attachments specified" unless @klass.respond_to?(:attachment_definitions)
if !name.blank? && @klass.attachment_names.include?(name) if !name.blank? && @klass.attachment_definitions.keys.include?(name)
[ name ] [ name ]
else else
@klass.attachment_definitions.keys @klass.attachment_definitions.keys
...@@ -19,9 +19,10 @@ namespace :paperclip do ...@@ -19,9 +19,10 @@ namespace :paperclip do
task :refresh => :environment do task :refresh => :environment do
klass = obtain_class klass = obtain_class
names = obtain_attachments names = obtain_attachments
instances = klass.find(:all)
puts "Regenerating thumbnails for #{instances.length} instances of #{klass.name}:" puts "Regenerating thumbnails for #{instances.length} instances of #{klass.name}:"
klass.find(:all).each do |instance| instances.each do |instance|
names.each do |name| names.each do |name|
result = if instance.send("#{ name }?") result = if instance.send("#{ name }?")
instance.send(name).send("post_process") instance.send(name).send("post_process")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment