2015-03-19 06:24:40 +00:00
|
|
|
class Group
|
|
|
|
include Mongoid::Document
|
2015-04-14 07:18:58 +00:00
|
|
|
include Mongoid::Timestamps
|
|
|
|
include Slug
|
2015-03-19 06:24:40 +00:00
|
|
|
|
2015-04-14 07:18:58 +00:00
|
|
|
field :title, as: :slug_title, type: String, localize: true
|
|
|
|
field :description, localize: true
|
|
|
|
field :admins, type: Array, default: []
|
|
|
|
field :privacy, default: "closed"
|
|
|
|
field :archive, type: Boolean, default: false
|
|
|
|
mount_uploader :image, ImageUploader
|
2015-03-19 06:24:40 +00:00
|
|
|
|
2015-04-14 07:18:58 +00:00
|
|
|
belongs_to :group_category
|
|
|
|
has_and_belongs_to_many :users
|
|
|
|
has_many :group_posts
|
|
|
|
|
|
|
|
scope :closed, ->{ where(privacy: "closed") }
|
|
|
|
scope :open, ->{ where(privacy: "open") }
|
|
|
|
scope :archived, ->{ where(archive: true) }
|
|
|
|
scope :not_archived, ->{ where(archive: false) }
|
2015-03-25 07:46:11 +00:00
|
|
|
|
2015-03-19 06:24:40 +00:00
|
|
|
|
|
|
|
end
|