orbit4-5/app/models/group.rb

20 lines
505 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"
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") }
end