class Template include Mongoid::Document include Mongoid::Timestamps include Mongoid::Slug include Mongoid::Elasticsearch field :title, type: String field :author, type: String field :template, type: String field :category_id, type: String field :price, type: Float field :description, type: String slug :title, history: true belongs_to :category has_many :previews, class_name: 'Preview' accepts_nested_attributes_for :previews mount_uploader :template, ProductUploader mount_uploader :thumbnail, ImageUploader elasticsearch! SORT_TYPE = %w{Popular New Preferred} def self.get_categories categories = Category.where(type: "Extension") end end