Sha256: 1e1203f28b787485be906c1cfbcfc8ce42908fdd5b1a1f27414d0b060ee018df
Contents?: true
Size: 1.05 KB
Versions: 9
Compression:
Stored size: 1.05 KB
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 before_save :clean_path # -- Validations ---------------------------------------------------------- validates :label, :presence => true validates :hostname, :presence => true, :uniqueness => { :scope => :path }, :format => { :with => /^[\w\.\-]+$/ } # -- Scopes --------------------------------------------------------------- scope :mirrored, where(:is_mirrored => true) protected def assign_label self.label = self.label.blank?? self.hostname : self.label end def clean_path self.path ||= '' self.path.squeeze!('/') self.path.gsub!(/\/$/, '') end end
Version data entries
9 entries across 9 versions & 1 rubygems