Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/rails/subdomain/mapper.rb
Defined Under Namespace
Classes: InvalidSubdomain
Instance Method Summary collapse
-
#subdomain(subdomain, options = {}, &block) ⇒ Object
Some sugar to specify subdomain constraints and defaults.
Instance Method Details
#subdomain(subdomain, options = {}, &block) ⇒ Object
Some sugar to specify subdomain constraints and defaults
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rails/subdomain/mapper.rb', line 5 def subdomain subdomain, ={}, &block subdomain = subdomain.to_s if subdomain.is_a? Symbol default = .delete :default default ||= subdomain raise InvalidSubdomain, %{Default subdomain must be a string, try `subdomain #{subdomain.inspect}, default: "blah"`} unless default.is_a? String raise InvalidSubdomain, %{Default subdomain must match subdomain constraint} unless subdomain === default scope .reverse_merge(:constraints => {:subdomain => subdomain}, :defaults => {:subdomain => default}), &block end |