Commit 1639f0ae by Jon Yurek

Changed metadata task to strip out bad chars and ignore non-present columns.

parent a7f01bec
......@@ -48,8 +48,9 @@ namespace :paperclip do
task :metadata => :environment do
for_all_attachments do |instance, name|
if file = instance.send(name).to_file
instance.send("#{name}_content_type=", file.content_type)
instance.send("#{name}_file_size=", file.size)
instance.send("#{name}_file_name=", instance.send("#{name}_file_name").strip.gsub(/[^\w\d\.\-]+/, '_'))
instance.send("#{name}_content_type=", file.content_type.strip)
instance.send("#{name}_file_size=", file.size) if instance.respond_to?("#{name}_file_size")
instance.save(false)
else
true
......
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