1class User < ActiveRecord::Base 2 has_many :sessions 3 has_many :videos 4 validates :email, email: true 5 6 has_secure_password 7 8 def login(password) 9 sessions.build if authenticate(password) 10 end 11end