Sha256: dd4690ff7e7dc937491d18ec715ed15a3dece39e59b2dd63a0e4bf621fc61e25

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

class Site
  include DataMapper::Resource
  include DataMapper::Timestamp
  
  # Schema
  property :id, Serial
  property :subdomain, String, :nullable => false, :length => (1..40), :unique => true, :format => /^[a-zA-Z0-9\-]*?$/
  property :created_at, DateTime
  property :updated_at, DateTime
  
  # Relationships/Associates
  has n, :users, :order => [:login.asc]
  
  # Validations
  validates_with_method :check_subdomain
  
  ReservedSubdomains = %w[backstage admin blog dev ftp mail email pop pop3 imap smtp stage stats status www]
  def check_subdomain
    if ReservedSubdomains.include?(self.subdomain)
      [false, "Subdomain '#{self.subdomain}' is reserved."]
    else
      true
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merb_auth_slice_multisite-0.8.6 app/models/site.rb