Skip to content

Commit

Permalink
Don't reopen AR::Base, include the module in ApplicationRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Feb 27, 2024
1 parent bd8ebfa commit e698c96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ApplicationRecord < ActiveRecord::Base
FIXTURE_DIR = Rails.root.join("db/fixtures")

include ActiveRecord::IdRegions
include ActsAsTaggable
include ArRegion
include ArLock
include ArNestedCountBy
Expand Down
15 changes: 5 additions & 10 deletions lib/extensions/ar_taggable.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
module ActiveRecord
class Base
def self.acts_as_miq_taggable
has_many :taggings, :as => :taggable, :dependent => :destroy
has_many :tags, :through => :taggings
include ActsAsTaggable
end
end
end

module ActsAsTaggable
extend ActiveSupport::Concern

Expand All @@ -30,6 +20,11 @@ def writable_classification_tags
end

module ClassMethods
def acts_as_miq_taggable
has_many :taggings, :as => :taggable, :dependent => :destroy
has_many :tags, :through => :taggings
end

# @option options :cat [String|nil] optional category for the tags
# @option options :ns [String|nil] optional namespace for the tags

Expand Down

0 comments on commit e698c96

Please sign in to comment.