Files
fizzy/app/models/user/accessor.rb
T
David Heinemeier Hansson 92ce80cc32 Extract User::Accessor concern
Our User model is getting overloaded
2025-04-05 12:34:39 +02:00

17 lines
460 B
Ruby

module User::Accessor
extend ActiveSupport::Concern
included do
has_many :accesses, dependent: :destroy
has_many :buckets, through: :accesses
has_many :accessible_bubbles, through: :buckets, source: :bubbles
after_create_commit :grant_access_to_buckets
end
private
def grant_access_to_buckets
Access.insert_all account.buckets.all_access.pluck(:id).collect { |bucket_id| { bucket_id: bucket_id, user_id: id } }
end
end