cd4fbc011c
Replace all occurrences of reverse_merge with with_defaults across the codebase. The with_defaults method provides clearer intent and better readability when setting default values for hash parameters. Changes: - app/helpers/columns_helper.rb: Update column_frame_tag method - app/models/user/email_address_changeable.rb: Update generate_email_address_change_token method - app/models/account.rb: Update create_with_owner method - app/controllers/concerns/filter_scoped.rb: Update filter_params method This refactoring maintains the same functionality while improving code clarity.
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
class Account < ApplicationRecord
|
|
include Account::Storage, Entropic, MultiTenantable, Seedeable
|
|
|
|
has_one :join_code
|
|
has_many :users, dependent: :destroy
|
|
has_many :boards, dependent: :destroy
|
|
has_many :cards, dependent: :destroy
|
|
has_many :webhooks, dependent: :destroy
|
|
has_many :tags, dependent: :destroy
|
|
has_many :columns, dependent: :destroy
|
|
has_many :exports, class_name: "Account::Export", dependent: :destroy
|
|
|
|
before_create :assign_external_account_id
|
|
after_create :create_join_code
|
|
|
|
validates :name, presence: true
|
|
|
|
class << self
|
|
def create_with_owner(account:, owner:)
|
|
create!(**account).tap do |account|
|
|
account.users.create!(role: :system, name: "System")
|
|
account.users.create!(**owner.with_defaults(role: :owner, verified_at: Time.current))
|
|
end
|
|
end
|
|
end
|
|
|
|
def slug
|
|
"/#{AccountSlug.encode(external_account_id)}"
|
|
end
|
|
|
|
def account
|
|
self
|
|
end
|
|
|
|
def system_user
|
|
users.find_by!(role: :system)
|
|
end
|
|
|
|
private
|
|
def assign_external_account_id
|
|
self.external_account_id ||= ExternalIdSequence.next
|
|
end
|
|
end
|