Files
fizzy/app/models/user/accessor.rb
T
2025-04-09 14:50:58 +02:00

17 lines
488 B
Ruby

module User::Accessor
extend ActiveSupport::Concern
included do
has_many :accesses, dependent: :destroy
has_many :collections, through: :accesses
has_many :accessible_cards, through: :collections, source: :cards
after_create_commit :grant_access_to_collections
end
private
def grant_access_to_collections
Access.insert_all account.collections.all_access.pluck(:id).collect { |collection_id| { collection_id: collection_id, user_id: id } }
end
end