Sha256: 54c2589b79d3dbc40b16fe1a70dee8dcf382e30b1069e3662616719758d13f63

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

class Dhatu::PromotionEnquiry < Dhatu::ApplicationRecord

  # Set Table Name
  self.table_name = "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

13 entries across 13 versions & 1 rubygems

Version Path
dhatu-0.3.0.pre.materialize app/models/dhatu/promotion_enquiry.rb
dhatu-0.2.3 app/models/dhatu/promotion_enquiry.rb
dhatu-0.2.2 app/models/dhatu/promotion_enquiry.rb
dhatu-0.2.1 app/models/dhatu/promotion_enquiry.rb
dhatu-0.2.0 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.25 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.24 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.23 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.22 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.21 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.20 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.19 app/models/dhatu/promotion_enquiry.rb
dhatu-0.1.18 app/models/dhatu/promotion_enquiry.rb