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 field :choose_lang, :type => Array, :default => ["en","zh_tw"] 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 def enabled_for?(lang) if lang.nil? return true else return self.choose_lang.include?(lang) end end end