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 mount_uploader :image, ImageUploader belongs_to :table_entry belongs_to :table_column def type self.table_column.type end def sort_value case self.type when "text" self.text when "editor" self.content when "image" self[:image] when "date" self.date when "period" [self.period_from,ce.period_to] end end end