Files
fizzy/app/models/user/accessor.rb
T
Jorge Manrubia f1d76a7cb7 Exclude inactive users
The system user should never be a subsriber but we should not serve it if it is
2025-09-17 13:26:53 +02:00

18 lines
578 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
has_many :accessible_comments, through: :accessible_cards, source: :comments
after_create_commit :grant_access_to_collections, unless: :system?
end
private
def grant_access_to_collections
Access.insert_all Collection.all_access.pluck(:id).collect { |collection_id| { collection_id: collection_id, user_id: id } }
end
end