f1d76a7cb7
The system user should never be a subsriber but we should not serve it if it is
18 lines
578 B
Ruby
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
|