Sha256: daa1956bb5b44f33921dc0192215070b610432e9247e9884aaa328ba5d954be3
Contents?: true
Size: 983 Bytes
Versions: 5
Compression:
Stored size: 983 Bytes
Contents
class Cms::Site < ActiveRecord::Base set_table_name :cms_sites # -- Relationships -------------------------------------------------------- has_many :layouts, :dependent => :destroy has_many :pages, :dependent => :destroy has_many :snippets, :dependent => :destroy has_many :uploads, :dependent => :destroy # -- Callbacks ------------------------------------------------------------ before_validation :assign_label # -- Validations ---------------------------------------------------------- validates :label, :presence => true validates :hostname, :presence => true, :uniqueness => true, :format => { :with => /^[\w\.\-]+$/ } # -- Class Methods -------------------------------------------------------- def self.options_for_select Cms::Site.all.collect{|s| ["#{s.label} (#{s.hostname})", s.id]} end protected def assign_label self.label = self.label.blank?? self.hostname : self.label end end
Version data entries
5 entries across 5 versions & 1 rubygems