class QaFile include Mongoid::Document include Mongoid::Timestamps mount_uploader :file, AssetUploader field :description, localize: true field :should_destroy, :type => Boolean field :title, localize: true belongs_to :qa def file_title if self.description.present? return self.description elsif self.title.present? return self.title else return File.basename(self.file.path) end end end