Sha256: 1942a774133b5b6c8e04d4ff07b94f2957b4b4f13d249fd005021b6b538037fd
Contents?: true
Size: 968 Bytes
Versions: 6
Compression:
Stored size: 968 Bytes
Contents
class SiteSignup < ActiveRecord::Base validates_format_of :email_address, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates :email_address, :name, :requested_url, :presence => true # validates_format_of :requested_url, :with => /^(?:[a-z0-9]_?)*[a-z](?:_?[a-z0-9])*$/i validate :uniqueness_and_format_of_url private def uniqueness_and_format_of_url website_url = "http://www.#{requested_url}.cloudcitysites.net" reg = Regexp.new(/^[\w\#{-}]*$/) result = reg.match(requested_url)? true : false if !result errors.add(:requested_url, 'Invalid url format! Use leters, numbers and _ ONLY') return result else domain_names = get_all_domain_names if domain_names domain_names.each do |domain| if requested_url == domain result = false end end end end result end def get_all_domain_names result = SignupService.find(:all) end end
Version data entries
6 entries across 6 versions & 1 rubygems