class Member < ApplicationRecord # Include default devise modules. Others available are: # , :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable,:confirmable, :recoverable, :rememberable, :validatable after_create :skip_conf! def skip_conf! self.confirm if Rails.env.development? end mount_uploader :picture, PictureUploader has_many :entities has_many :profiles Profile.kinds.each do |kind| define_method :"#{kind}_profile" do Profile.where( member_id: self.id).where(kind: kind).first end end def profile( kind ) Profile.where( member_id: self.id).where(kind: kind).first end def teacher profile( :teacher ) end def future_events teacher = profile( :teacher ) return [] unless teacher teacher.future_events end def admin? ["torsten@villataika.fi" , "info@hubfeenix.fi" , "hannaholma@gmail.com" , "maijanposteja@gmail.com", ].include?(email) end alias :admin :admin? end