PHC MTWarden Rails 5.1 engine adds a separate multi-tenant layer that handles all user registrations, multi-tenancy app functions, and login through subdomains using Warden authentication gem.
gem 'mtwarden', '~> 17.0'
bundle exec install
rake railties:install:migrations
rake db:migrate
Add this line at the top of the routes.rb file.
require 'mtwarden/constraints/subdomain_required'
Add this line at the end of the routes.rb file.
mount Mtwarden::Engine, :at => '/'
All the routes you want to have multi-tenancy login functions goes in between the constraints block.
constraints(Mtwarden::Constraints::SubdomainRequired) do
# Routes Requiring Security & Multi-Tenancy Routes
end