Account.sole → Current.account

and some other de-tenant changes, including removing the controller
tenanting concerns
This commit is contained in:
Mike Dalessio
2025-11-10 07:58:40 -05:00
parent 6705b5225f
commit d41d50d52b
40 changed files with 67 additions and 96 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ Current.set(
# Step 3: Get or create join code
ApplicationRecord.with_tenant(tenant_id) do
account = Account.sole
account = Current.account
join_code = account.join_code
puts "✓ Join code ready"
+2 -2
View File
@@ -35,7 +35,7 @@ require_relative "../config/environment"
tenant = ActiveRecord::FixtureSet.identify(identifier)
ApplicationRecord.with_tenant(tenant) do |tenant|
Account.sole.destroy!
Current.account.destroy!
Account.create_with_admin_user \
account: { name: "Company #{identifier}" },
@@ -48,6 +48,6 @@ ApplicationRecord.with_tenant(tenant) do |tenant|
board.accesses.grant_to(user)
end
url = Rails.application.routes.url_helpers.root_url(Rails.application.config.action_controller.default_url_options.merge(script_name: Account.sole.slug))
url = Rails.application.routes.url_helpers.root_url(Rails.application.config.action_controller.default_url_options.merge(script_name: Current.account.slug))
puts "\n\nLogin to #{url} as #{user.email_address} / secret123456"
end
@@ -15,13 +15,13 @@ ApplicationRecord.with_each_tenant do |tenant|
# Create a new Identity
Identity.transaction do
identity = Identity.create!
user.membership = identity.memberships.create!(user_id: user.id, user_tenant: user.tenant, email_address: user.email_address, account_name: Account.sole.name)
user.membership = identity.memberships.create!(user_id: user.id, user_tenant: user.tenant, email_address: user.email_address, account_name: Current.account.name)
puts "Created identity #{identity.id} for user #{user.id} (#{user.email_address})"
end
else
# Merge this User's Membership into the existing Identity
identity = memberships.first.identity
user.membership = identity.memberships.create!(user_id: user.id, user_tenant: user.tenant, email_address: user.email_address, account_name: Account.sole.name)
user.membership = identity.memberships.create!(user_id: user.id, user_tenant: user.tenant, email_address: user.email_address, account_name: Current.account.name)
puts "Merged membership for user #{user.id} (#{user.email_address}) into identity #{identity.id}"
end
end
@@ -25,7 +25,7 @@ def fix_attachments(rich_text)
end
ApplicationRecord.with_each_tenant do |tenant|
account_id = Account.sole.queenbee_id
account_id = Current.account.queenbee_id
unless account_id
puts "Skipping URL fixup for tenant: #{tenant}"
@@ -37,7 +37,7 @@ ApplicationRecord.with_each_tenant do |tenant|
domain = domains[Rails.env] || domains["production"]
regex = %r{://\w+\.#{domain}/}
pp [ Account.sole.name, account_id, domain, regex ]
pp [ Current.account.name, account_id, domain, regex ]
puts
Card.find_each do |card|