There are several ways to do this, especially it will be interesting for you multi-tenancyto look regarding rails.
-
Apartment house
While multiple leases are usually a determination of the presence of several databases / assets (one for each user), since it is ridiculously difficult to get this to work on rails (which we are working on now), you can use the principle with one data stack
There are several guides on how to achieve this with Rails here:
, " "
" "
-
Rails . , :
constraints Subdomain do
namespace :accounts, path: "" do
root to: "application#show"
end
end
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != 'www'
end
end
:
class Account::ApplicationController < ActionController::Base
before_action :set_account
def show
end
private
def set_account
params[:id] ||= request.subdomains.first unless request.subdomains.blank?
@account = Account.find params[:id]
end
end
, , , , !
@account:
<%= @account.name %>