DEV: Add true_fields method for CustomFields (#24876)

This is useful for plugins that might otherwise rely on the
CUSTOM_FIELD_TRUE constant.
This commit is contained in:
Daniel Waterworth
2023-12-14 11:06:21 -06:00
committed by GitHub
parent 74f964f2b4
commit d7a09fb08d
7 changed files with 47 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class CategoryCustomField < ActiveRecord::Base
include CustomField
belongs_to :category
end

View File

@@ -0,0 +1,11 @@
# frozen_string_literal: true
module CustomField
extend ActiveSupport::Concern
class_methods do
def true_fields
where(value: HasCustomFields::Helpers::CUSTOM_FIELD_TRUE)
end
end
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class GroupCustomField < ActiveRecord::Base
include CustomField
belongs_to :group
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class PostCustomField < ActiveRecord::Base
include CustomField
belongs_to :post
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class TopicCustomField < ActiveRecord::Base
include CustomField
belongs_to :topic
end

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class UserCustomField < ActiveRecord::Base
include CustomField
belongs_to :user
scope :searchable,