Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Releases: obie/after_attached

v0.1.1 - Fix GitHub URLs

31 Jul 21:55

Choose a tag to compare

🔧 Patch Release

This patch release corrects the GitHub repository URLs in the gemspec and documentation.

Fixed

  • Updated all GitHub URLs from to
  • Corrected links in README and gemspec

Installation

gem 'after_attached', '~> 0.1.1'

No functional changes in this release - all the same great attachment lifecycle callbacks from v0.1.0!

v0.1.0 - Initial Release

31 Jul 18:32

Choose a tag to compare

🎉 Initial Release

AfterAttached provides comprehensive attachment lifecycle callbacks for Rails models with Active Storage attachments.

Features

  • Complete lifecycle callbacks:

    • before_attached - runs before an attachment is saved
    • after_attached - runs after an attachment is committed to the database
    • before_detached - runs before an attachment is destroyed
    • after_detached - runs after an attachment is destroyed and committed
  • Flexible callback definition:

    • Use method symbols or blocks
    • Define multiple callbacks per attachment
    • Works with both has_one_attached and has_many_attached
  • Automatic integration:

    • Automatically included in all Active Record models
    • No configuration required

Installation

Add to your Gemfile:

gem 'after_attached', '~> 0.1.0'

Example Usage

class User < ApplicationRecord
  has_one_attached :avatar
  
  after_attached :avatar do |attachment|
    AvatarProcessingJob.perform_later(self, attachment)
  end
  
  before_detached :avatar do |attachment|
    Rails.logger.info "Removing avatar: #{attachment.filename}"
  end
end

See the README for full documentation.