Module: Anchormodel::ModelMixin

Extended by:
ActiveSupport::Concern
Defined in:
lib/anchormodel/model_mixin.rb

Overview

Include this mixin in every Rails model that uses anchormodel attributes. The common pattern is to include it once in application_record.rb so all descendant models pick it up automatically.

Adds two class-level macros:

  • ClassMethods#belongs_to_anchormodel for single-value attributes
  • ClassMethods#belongs_to_anchormodels for collection-valued attributes

Examples:

Install in ApplicationRecord

class ApplicationRecord < ActiveRecord::Base
  include Anchormodel::ModelMixin
end