forked from saurabh/orbit4-5
23 lines
622 B
Ruby
23 lines
622 B
Ruby
class Group
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include Slug
|
|
|
|
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
|
|
|
|
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) }
|
|
|
|
|
|
end |