Module: SubdomainRoutes::Validations::ClassMethods
- Defined in:
- lib/subdomain_routes/validations.rb
Instance Method Summary collapse
- #validates_subdomain_format_of(*attr_names) ⇒ Object
- #validates_subdomain_not_reserved(*attr_names) ⇒ Object
Instance Method Details
#validates_subdomain_format_of(*attr_names) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/subdomain_routes/validations.rb', line 15 def validates_subdomain_format_of(*attr_names) configuration = { :on => :save } configuration.update(attr_names.) validates_each(attr_names, configuration) do |record, attr_name, value| unless SubdomainRoutes.valid_subdomain?(value) record.errors.add(attr_name, :not_a_valid_subdomain, :default => configuration[:message], :value => value) end end end |
#validates_subdomain_not_reserved(*attr_names) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/subdomain_routes/validations.rb', line 26 def validates_subdomain_not_reserved(*attr_names) configuration = { :on => :save } configuration.update(attr_names.) validates_each(attr_names, configuration) do |record, attr_name, value| if ActionController::Routing::Routes.reserved_subdomains.include? value record.errors.add(attr_name, :is_a_reserved_subdomain, :default => configuration[:message], :value => value) end end end |