Open mehulkar opened 9 years ago
The only related issue I see is this https://github.com/jstorimer/delayed_paperclip/issues/34
My current solution is to monkey patch paperclip's Attachment#assign
method, but this makes me really uneasy
module Paperclip
class Attachment
alias_method :old_assign, :assign
def assign(uploaded_file)
mark_processing(false)
old_assign(uploaded_file)
mark_processing(true) if post_processing
end
def mark_processing(bool)
Rails.logger.debug("Marking Attachment#{instance.id}.processed as #{bool}")
# this hackery is so we don't call save when a file is being assigned to a new record
if instance.id.present?
instance.update_attributes(processed: bool)
else
instance.assign_attributes(processed: bool)
end
end
end
end
Hey @mehulkar can you add your paperclip, delayed_paperclip and rails version please?
Rails 4.0.4, Paperclip: 4.2.1, delayed_paperclip 2.8.0
$ rails --version
Rails 4.0.4
$ gem list paperclip
*** LOCAL GEMS ***
delayed_paperclip (2.8.0)
paperclip (4.2.1, 4.2.0)
$ cat Gemfile.lock| grep paperclip
delayed_paperclip (2.8.0)
paperclip (>= 3.3)
paperclip (4.2.1)
delayed_paperclip (= 2.8.0)
paperclip (~> 4.1)
Hey @mehulkar I'm not exactly sure why your setting these before/post processed call backs. Was there an issue with the processing column that you were trying to fix? If so, it might have been fixed by https://github.com/jrgifford/delayed_paperclip/pull/125 which was just merged
A coworker had added a data_processing
column before I got on the project, but it didn't seem to be doing anything, so I was forced to roll my own. I can try using the inbuilt version again. Does #125 merit a version bump to make it easier for me to get a locked down version, rather than point to master?
I've added the following code to my attachment model:
When I comment out the
process_in_background
directive, the attachment is successfully updated asprocessed: true
, but when Iprocess_in_background
, it looks like the callbacks are not run. I'm not sure how to debug this.