A few things to note when trying to process an uploaded file with paperclip:
- The only way a post-processor will run is if a style is defined
class MyModel < ActiveRecord::Base
has_attached_file :mp3,
:url => '/:class/:id/:style.:extension',
:path => ':rails_root/assets/:class/:id_partition/:style.:extension',
:whiny => true,
:styles => { :text => { :do_something => true } },
:processors => [:my_processor]
# ...
end
- To access the file after processing but before paperclip is finished, use the :after_process callback — model instance attributes can be modified and will be saved automatically as part of the paperclip process
class MyModel < ActiveRecord::Base
# ...
after_post_process :do_one_more_thing
# ...
private
def do_one_more_thing
logger.info "MyModel [paperclip] after_post_process"
logger.info "MyModel [paperclip] file #{mp3.queued_for_write[:original].path}"
# Do more with the file
# Make model attribute changes as needed
# self.my_attribute = "x"
end
end
- View paperclip documentation at http://dev.thoughtbot.com/paperclip/
No need to restart by following this post:
http://www.hostingrails.com/401/What-is-the-best-practice-for-rails-log-rotation-How-to-use-logrotate
#!/bin/sh
mkdir /mnt/app/releases/mysite.com/log/archive -p
tar czf "/mnt/app/releases/mysite.com/log/archive/`date +%Y%m%d`_production.tar.gz" -C / mnt/app/releases/mysite.com/log/production.log
cat /dev/null > /mnt/app/releases/mysite.com/log/production.log
find /mnt/app/releases/mysite.com/log/archive/* -mtime +180 -exec rm {} \;