1. Simple after_commit plugin

    In case you want to ensure files are written/deleted only if the commit succeeds, this plugin is for you.

    what it does

    The plugin simply adds the after_commit method to your ActiveRecord models and ensures that the code in the block is only executed if and after the top-most transaction succeeds.

    usage

    Once the plugin is in the vendor/plugins folder, you can write the following code in your save/destroy hooks (or anywhere else that is run inside a transaction):

    def some_callback
      after_commit do
        # write file, clear cache, etc
      end
    end
    

    download

    Get the plugin here

    [edit]

    The plugin is now part of the new versions gem which enables automatic versioning, multiversions and shared attachments.

    Gaspard Bucher

    comments

    1. leave a comment