Consider the current tenant in email URLs
This commit is contained in:
@@ -6,7 +6,25 @@ class ApplicationMailer < ActionMailer::Base
|
||||
layout "mailer"
|
||||
before_action :set_asset_host
|
||||
|
||||
def default_url_options
|
||||
if Tenant.default?
|
||||
super
|
||||
else
|
||||
super.merge(host: host_with_subdomain_for(super[:host]))
|
||||
end
|
||||
end
|
||||
|
||||
def set_asset_host
|
||||
self.asset_host ||= root_url.delete_suffix("/")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def host_with_subdomain_for(host)
|
||||
if host == "localhost"
|
||||
"#{Tenant.current_schema}.lvh.me"
|
||||
else
|
||||
"#{Tenant.current_schema}.#{host}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user