Sha256: ed4606e5ed96c7a4a92f7b189ea25100269477d428864d34982b972a3efbdba7
Contents?: true
Size: 335 Bytes
Versions: 4
Compression:
Stored size: 335 Bytes
Contents
class AddApiKeyToUsers < ActiveRecord::Migration def change add_column :users, :api_key, :string, limit: 32 User.where('api_key IS NULL').find_each do |user| begin user.api_key = SecureRandom.uuid.tr('-', '') end while User.where(api_key: user.api_key).any? user.save! end end end
Version data entries
4 entries across 4 versions & 1 rubygems