Skip to main content

active_support_concern_modules

📦 Modularize Code with ActiveSupport::Concern​

ActiveSupport::Concern streamlines shared module creation by handling included blocks and dependency declarations. This keeps your models/controllers DRY and organized.

module Trackable
extend ActiveSupport::Concern

included do
before_save :track_changes
end

def track_changes
# custom tracking logic here
end
end

class User < ApplicationRecord
include Trackable
end