Sha256: beb68ae0c2ff7bb5ae4d7bff6cb132125cbcf7b65ebb6bc0163dec9cf9fb32a6
Contents?: true
Size: 1.38 KB
Versions: 7
Compression:
Stored size: 1.38 KB
Contents
class Dhatu::Booking < Dhatu::ApplicationRecord # Set Table Name self.table_name = "dhatu_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, optional: true # 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
7 entries across 7 versions & 1 rubygems