Module: ActionDispatch::Routing::Mapper::HttpHelpers
- Defined in:
- lib/ensure_subdomain.rb
Instance Method Summary collapse
- #ensure_no_www ⇒ Object (also: #ensure_non_www, #ensure_apex)
- #ensure_on(environments) ⇒ Object
- #ensure_subdomain(subdomain, options = {}) ⇒ Object
- #ensure_www ⇒ Object
Instance Method Details
#ensure_no_www ⇒ Object Also known as: ensure_non_www, ensure_apex
32 33 34 |
# File 'lib/ensure_subdomain.rb', line 32 def ensure_no_www ensure_subdomain '' end |
#ensure_on(environments) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/ensure_subdomain.rb', line 42 def ensure_on(environments) environments.each_pair do |env, domain| if Rails.env.to_sym == env ensure_subdomain domain end end end |
#ensure_subdomain(subdomain, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/ensure_subdomain.rb', line 50 def ensure_subdomain(subdomain, ={}) redirector = EnsureSubdomain.new( subdomain ) verbs = [:via] || [:get, :post, :put, :patch, :delete] constraints( redirector ) do match '/', to: redirect { |params, request| redirector.to params, request }, via: verbs match '/*path', to: redirect { |params, request| redirector.to params, request }, via: verbs end end |
#ensure_www ⇒ Object
38 39 40 |
# File 'lib/ensure_subdomain.rb', line 38 def ensure_www ensure_subdomain 'www' end |