Add view for StudyGroups

This commit is contained in:
Sebastian Serth
2018-12-14 14:52:04 +01:00
parent 9061a07763
commit 7983c0797a
13 changed files with 168 additions and 9 deletions

View File

@ -1,7 +1,8 @@
class Consumer < ApplicationRecord
has_many :users
scope :with_users, -> { where('id IN (SELECT consumer_id FROM internal_users)') }
scope :with_internal_users, -> { where('id IN (SELECT DISTINCT consumer_id FROM internal_users)') }
scope :with_study_groups, -> { where('id IN (SELECT DISTINCT consumer_id FROM study_groups)') }
validates :name, presence: true
validates :oauth_key, presence: true, uniqueness: true