class ColumnEntry include Mongoid::Document include Mongoid::Timestamps field :text, :localize => true field :content, :localize => true field :date, type: DateTime field :period_from, type: DateTime field :period_to, type: DateTime field :number, type: Integer mount_uploader :image, ImageUploader belongs_to :table_entry, :dependent => :destroy, index: true belongs_to :table_column, :dependent => :destroy, index: true I18n.available_locales.each do |locale| index({text: 1}, { collation: {locale: locale.to_s}, unique: false, background: true }) index({content: 1}, { collation: {locale: locale.to_s}, unique: false, background: true }) end def type self.table_column.type end end