Skip to content

Commit

Permalink
Add after_commit support
Browse files Browse the repository at this point in the history
If not, application crashes on Heroku.
  • Loading branch information
florentmorin committed Feb 19, 2014
1 parent 07c37ed commit b92dfeb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/mongoid_paperclip.rb
Expand Up @@ -62,6 +62,26 @@ def self.included(base)
end

module ClassMethods

##
# Adds after_commit
def after_commit(*args, &block)
options = args.pop if args.last.is_a? Hash
if options
case args[:on]
when :create
after_create(*args, &block)
when :update
after_update(*args, &block)
when :destroy
after_destroy(*args, &block)
else
after_save(*args, &block)
end
else
after_save(*args, &block)
end
end

##
# Adds Mongoid::Paperclip's "#has_mongoid_attached_file" class method to the model
Expand Down

0 comments on commit b92dfeb

Please sign in to comment.