working on authentication

This commit is contained in:
Jared Cosulich 2017-04-05 21:17:27 -04:00
parent f3392f685d
commit a018c42e0f
17 changed files with 154 additions and 80 deletions

View file

@ -3,4 +3,15 @@ class User < ApplicationRecord
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :user_schools
def schools
districts = user_schools.map(&:district).compact.uniq
(user_schools.map(&:school) + districts.map(&:schools)).flatten.compact.uniq
end
def admin?(school)
schools.index(school).present?
end
end

View file

@ -0,0 +1,7 @@
class UserSchool < ApplicationRecord
belongs_to :user
belongs_to :school
belongs_to :district
end