Sha256: 3936b113866b6b9e629d5d1390e57fbbe4bf97e0d825af2a4dc85037f9800b46
Contents?: true
Size: 1.3 KB
Versions: 11
Compression:
Stored size: 1.3 KB
Contents
class Dhatu::Booking < Dhatu::ApplicationRecord # Set Table Name self.table_name = "bookings" # Including the State Machine Methods include Readable include Featureable # Validations validates :name, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: false # validate_email :email, mandatory: false, allow_blank: true validates :mobile, length: {maximum: 250}, allow_blank: true # Associations belongs_to :service # ------------------ # 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 variables # ------------------ # 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
11 entries across 11 versions & 1 rubygems