app/models/user.rb in hackathon_manager-0.12.2 vs app/models/user.rb in hackathon_manager-0.13.0

- old
+ new

@@ -11,10 +11,17 @@ foreign_key: :resource_owner_id, dependent: :delete_all # or :destroy if you need callbacks after_create :queue_reminder_email + enum role: { user: 0, event_tracking: 1, admin_limited_access: 2, admin: 3 } + after_initialize :set_default_role, if: :new_record? + + def set_default_role + self.role ||= :user + end + def active_for_authentication? true end def send_devise_notification(notification, *args) @@ -54,9 +61,13 @@ user.email = auth.info.email user.password = Devise.friendly_token[0, 20] end end + def self.non_admins + User.where.not(role: :admin).where.not(role: :admin_limited_access) + end + def self.without_questionnaire - User.left_outer_joins(:questionnaire).where(questionnaires: { id: nil }, admin: false) + non_admins.left_outer_joins(:questionnaire).where(questionnaires: { id: nil }) end end