Module: ActionDispatch::Routing::Mapper::HttpHelpers
- Defined in:
- lib/action_dispatch/routing/mapper/http_helpers.rb
Instance Method Summary collapse
- #ensure_no_www ⇒ Object (also: #ensure_non_www, #ensure_apex)
- #ensure_on(environments) ⇒ Object
- #ensure_subdomain(subdomain, options = {}) ⇒ Object (also: #ensure_subdomains)
- #ensure_www ⇒ Object
Instance Method Details
#ensure_no_www ⇒ Object Also known as: ensure_non_www, ensure_apex
2 3 4 |
# File 'lib/action_dispatch/routing/mapper/http_helpers.rb', line 2 def ensure_no_www ensure_subdomain '' end |
#ensure_on(environments) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/action_dispatch/routing/mapper/http_helpers.rb', line 12 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 Also known as: ensure_subdomains
20 21 22 23 24 25 26 27 |
# File 'lib/action_dispatch/routing/mapper/http_helpers.rb', line 20 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
8 9 10 |
# File 'lib/action_dispatch/routing/mapper/http_helpers.rb', line 8 def ensure_www ensure_subdomain 'www' end |