class BulletinFile

  include Mongoid::Document
  include Mongoid::Timestamps

  mount_uploader :file, AssetUploader
  
  # field :filetitle
  # field :description
  has_one :filetitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
  has_one :description, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
  
  # field :to_save, :type => Boolean
  field :should_destroy, :type => Boolean
  
  belongs_to :bulletin
  # embedded_in :bulletin
  
  
  protected
  
  def set_key
    if filetitle.new_record?
      filetitle.key = 'filetitle'
    end
    if description.new_record?
      description.key = 'description'
    end
  end  

end
