Sha256: 6a3219e9df338c77d2c4bbb53baeb9bd1b5578585cb2a81fb13fa147d0014333
Contents?: true
Size: 1.21 KB
Versions: 9
Compression:
Stored size: 1.21 KB
Contents
class Dhatu::MetaTag < Dhatu::ApplicationRecord # Constants META_TYPES = ["Default", "Open Graph", "Twitter", "Facebook", "Other"] # Set Table Name self.table_name = "dhatu_meta_tags" # Including the State Machine Methods include Publishable # Validations validates :meta_type, presence: true, length: {minimum: 3, maximum: 16}, allow_blank: false validates :meta_key, presence: true, length: {minimum: 1, maximum: 128}, allow_blank: false validates :meta_value, presence: true, length: {minimum: 1, maximum: 1064}, allow_blank: false # Associations belongs_to :meta_taggable, :polymorphic => true # ------------------ # Class Methods # ------------------ scope :search, lambda { |query| where("LOWER(meta_type) LIKE LOWER('%#{query}%') OR LOWER(meta_key) LIKE LOWER('%#{query}%') OR LOWER(meta_value) LIKE LOWER('%#{query}%')") } # ------------------ # Instance Methods # ------------------ # Generic Methods # --------------- def display_name "#{self.meta_type_was} - #{self.meta_key_was}" end # Permission Methods # ------------------ def can_be_edited? status?(:published) or status?(:unpublished) end def can_be_deleted? status?(:removed) end end
Version data entries
9 entries across 9 versions & 1 rubygems