Skip to content

Instantly share code, notes, and snippets.

@leandroh
Forked from leandroo/gist:281513
Created January 20, 2010 11:12
Show Gist options
  • Save leandroh/281771 to your computer and use it in GitHub Desktop.
Save leandroh/281771 to your computer and use it in GitHub Desktop.
class Pedido < ActiveRecord::Base
def gera_numero_pedido
self.numero = Array.new(9){rand(9)}.join while self.numero.nil? or Pedido.find_by_numero(self.numero)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment