Sha256: 6498305e6a87cf62dbe7ec9121c176f56ae2e326aba7b74655bf29060d2d4f56
Contents?: true
Size: 1.81 KB
Versions: 11
Compression:
Stored size: 1.81 KB
Contents
class Dhatu::TeamMember < Dhatu::ApplicationRecord # Set Table Name self.table_name = "team_members" # Including the State Machine Methods include Publishable include Featureable # Validations validates :name, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: false validates :designation, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: true validates :description, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: true # Associations has_one :profile_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::ProfileImage" # ------------------ # Class Methods # ------------------ scope :search, lambda {|query| where(" LOWER(name) LIKE LOWER('%#{query}%') OR\ LOWER(designation) LIKE LOWER('%#{query}%') OR\ LOWER(status) LIKE LOWER('%#{query}%') OR\ LOWER(linked_in_url) LIKE LOWER('%#{query}%') OR\ LOWER(google_plus_url) LIKE LOWER('%#{query}%') OR\ LOWER(facebook_url) LIKE LOWER('%#{query}%') OR\ LOWER(twitter_url) 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? status?(:published) or status?(:unpublished) end def can_be_deleted? status?(:removed) end end
Version data entries
11 entries across 11 versions & 1 rubygems