26 lines
666 B
Ruby
26 lines
666 B
Ruby
class Member < ApplicationRecord
|
|
# Include default devise modules. Others available are:
|
|
# , :lockable, :timeoutable, :trackable and :omniauthable
|
|
devise :database_authenticatable, :registerable,:confirmable,
|
|
:recoverable, :rememberable, :validatable
|
|
|
|
mount_uploader :picture, PictureUploader
|
|
|
|
has_many :entities
|
|
has_many :profiles
|
|
|
|
Profile.types.each do |kind|
|
|
define_method :kind 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 admin?
|
|
email == "torsten@villataika.fi"
|
|
end
|
|
alias :admin :admin?
|
|
end
|