Skip to content

Instantly share code, notes, and snippets.

@shishi
Created March 11, 2014 10:04

Revisions

  1. shishi created this gist Mar 11, 2014.
    16 changes: 16 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # 1
    begin
    key = SecureRandom.hex 5
    end while self.find_by(migration_key: key)

    key

    # 2
    key = SecureRandom.hex 5
    if User.find_by(migration_key: key)
    create_migration_key
    else
    key
    end