residency/app/models/member.rb

36 lines
865 B
Ruby
Raw Normal View History

2022-12-20 17:05:26 +02:00
class Member < ApplicationRecord
2023-10-23 11:18:53 +03:00
after_create :skip_conf!
2023-05-24 17:52:52 +03:00
2023-02-03 17:27:42 +02:00
def self.public_scope
where.not(confirmed_at: nil).where.not(picture: nil)
end
2023-06-18 11:23:46 +03:00
def self.visible_scope
where.not(confirmed_at: nil).where.not(arriving: nil)
end
2022-12-20 17:29:05 +02:00
# Include default devise modules. Others available are:
# , :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,:confirmable,
2023-01-24 19:04:53 +02:00
:recoverable, :rememberable, :validatable, :async
2022-12-22 16:45:55 +02:00
2022-12-25 17:37:22 +02:00
mount_uploader :picture, PictureUploader
2023-01-11 20:52:58 +02:00
has_many :stories
2023-01-25 22:15:54 +02:00
has_many :stories
has_many :pictures
2023-10-23 11:18:53 +03:00
def skip_conf!
2023-10-23 11:33:18 +03:00
self.confirm if Rails.env.development?
2023-10-23 11:18:53 +03:00
end
2023-01-22 20:29:10 +02:00
validates :bio, length: { maximum: 1000 }
validates :name , length: { minimum: 3 }
2022-12-31 22:01:51 +02:00
def admin
2023-01-12 22:24:36 +02:00
self.email == "torsten@villataika.fi"
2022-12-31 22:01:51 +02:00
end
2022-12-22 16:45:55 +02:00
def admin?
2023-01-12 22:24:36 +02:00
self.email == "torsten@villataika.fi"
2022-12-22 16:45:55 +02:00
end
2022-12-20 17:05:26 +02:00
end