hubfeenix.fi/app/models/member.rb

26 lines
679 B
Ruby
Raw Normal View History

2022-12-20 16:05:26 +01:00
class Member < ApplicationRecord
2022-12-20 16:29:05 +01:00
# Include default devise modules. Others available are:
# , :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,:confirmable,
:recoverable, :rememberable, :validatable
2022-12-22 15:45:55 +01:00
2022-12-25 16:37:22 +01:00
mount_uploader :picture, PictureUploader
has_many :entities
2023-01-16 00:11:05 +01:00
has_many :profiles
2023-01-20 13:59:34 +01:00
Profile.kinds.each do |kind|
define_method :"#{kind}_profile" do
2023-01-16 00:11:05 +01:00
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
2022-12-22 15:45:55 +01:00
def admin?
2023-01-15 13:52:40 +01:00
email == "torsten@villataika.fi"
2022-12-22 15:45:55 +01:00
end
2023-01-15 13:52:40 +01:00
alias :admin :admin?
2022-12-20 16:05:26 +01:00
end