first commit, largely copied volunteers
This commit is contained in:
3
app/models/application_record.rb
Normal file
3
app/models/application_record.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
primary_abstract_class
|
||||
end
|
0
app/models/concerns/.keep
Normal file
0
app/models/concerns/.keep
Normal file
35
app/models/member.rb
Normal file
35
app/models/member.rb
Normal file
@ -0,0 +1,35 @@
|
||||
class Member < ApplicationRecord
|
||||
after_create :skip_conf!
|
||||
|
||||
def self.public_scope
|
||||
where.not(confirmed_at: nil).where.not(picture: nil)
|
||||
end
|
||||
|
||||
def self.visible_scope
|
||||
where.not(confirmed_at: nil)
|
||||
end
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# , :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,:confirmable,
|
||||
:recoverable, :rememberable, :validatable, :async
|
||||
|
||||
def skip_conf!
|
||||
self.confirm if Rails.env.development?
|
||||
end
|
||||
|
||||
mount_uploader :picture, PictureUploader
|
||||
has_many :stories
|
||||
has_many :stories
|
||||
has_many :pictures
|
||||
|
||||
validates :bio, length: { maximum: 1000 }
|
||||
validates :name , length: { minimum: 3 }
|
||||
|
||||
def admin
|
||||
self.email == "torsten@villataika.fi"
|
||||
end
|
||||
def admin?
|
||||
self.email == "torsten@villataika.fi"
|
||||
end
|
||||
end
|
10
app/models/picture.rb
Normal file
10
app/models/picture.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class Picture < ApplicationRecord
|
||||
belongs_to :member
|
||||
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
validates :text, length: { maximum: 80 }
|
||||
validates :happened, presence: true
|
||||
validates :picture, presence: true
|
||||
|
||||
end
|
13
app/models/story.rb
Normal file
13
app/models/story.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class Story < ApplicationRecord
|
||||
belongs_to :member
|
||||
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
validates :text, length: { minimum: 5 , maximum: 1000 }
|
||||
validates :header , length: { minimum: 5 , maximum: 400}
|
||||
validates :picture, presence: true
|
||||
|
||||
def name
|
||||
header
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user