Module: Railings::Domains

Defined in:
lib/railings/domains.rb

Defined Under Namespace

Classes: Subdomain

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object



20
21
22
# File 'lib/railings/domains.rb', line 20

def const_missing name
  save name, Subdomain.new(name)
end

.save(name, subdomain) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/railings/domains.rb', line 24

def save name, subdomain
  const_set(name, subdomain).tap do
    ApplicationController.send :helper, Module.new do
      define_method "url_for_#{name.downcase}" do |options|
        unless subdomain == request.subdomain
          options[:host]      = with_subdomain subdomain
          options[:only_path] = false
        end
        options
      end
    end
  end
end