Sha256: d3475918c151ef068fc79fc1534a47ea6ba20e7d0ecc881696c092436620feee

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

class Dhatu::PromotionEnquiry < Dhatu::ApplicationRecord

  # Set Table Name
  self.table_name = "dhatu_promotion_enquiries"

  # Including the State Machine Methods
  include Readable
  include Featureable

  # Validations
  

  # Associations
  belongs_to :promotion

  # Serializers
  serialize :additional_attributes, Hash
  
  # ------------------
  # Class Methods
  # ------------------

  scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%') OR\
                                        LOWER(email) LIKE LOWER('%#{query}%') OR\
                                        LOWER(mobile) LIKE LOWER('%#{query}%') OR\
                                        LOWER(message) LIKE LOWER('%#{query}%')")}
  
  scope :upcoming, lambda { where("created_at >= ?", Time.now) }
  scope :past, lambda { where("created_at < ?", Time.now) }

  # ------------------
  # Instance Methods
  # ------------------

  # Generic Methods
  # ---------------
  def to_param
    "#{id}-#{name.parameterize[0..32]}"
  end

  def display_name
    "#{name_was}"
  end

  # Permission Methods
  # ------------------

  def can_be_edited?
    false
  end

  def can_be_deleted?
    status?(:removed)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dhatu-0.3.9.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.8.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.7.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.6.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.5.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.4.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.3.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.2.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.3.1.pre.materialize app/models/dhatu/promotion_enquiry.rb