Last Updated: February 25, 2016
·
1.975K
· dfang

some tips on rails subdomain

1 . implement subdomain name in rails

2 . third-level domain support

add config.action_dispatch.tld_length = 2 to development.rb

see rails api( url_for :tld_length option )

3 . set domain key in session_store.rb to keep session

redirecting from domain.com to sub.domain.com will lose session unless you set domain option in session_store.rb.

Vfolio::Application.config.session_store :cookie_store, key: '_vfolio_session', domain: '.xxxxx.ekohe.com'

the default session_store.rb generated by rails has no domain option, and set domain option to domain: :all is a trap

4 . use lvh.me test subdomain locally(https://coderwall.com/p/bggmvq) or use dnsmasq to set your dns

5 .session_store.rb and secret_token.rb should be created as link in deploy.rb, replace secret token when deploying