class MailArchive < ActiveRecord::Base
  belongs_to :newsletter
  belongs_to :archive_newsletter

  belongs_to :annonce_account
  
  before_create do
    self.generate_token
  end
  
  def generate_token
    begin
      self[:token] = SecureRandom.urlsafe_base64
    end while MailArchive.exists?(:token => self[token])
  end
  
end
