Sha256: 9a48c5fdccf4ac18075fc4fd5146ca0fdae14059434ed0eb6f3143c3f12c74e9
Contents?: true
Size: 1.1 KB
Versions: 35
Compression:
Stored size: 1.1 KB
Contents
= Create an account record programmatically In some scenarios you might want to create an account records programmatically, for example in your tests. If you're storing passwords in a separate table, you can create an account records as follows: account_id = DB[:accounts].insert( email: "name@example.com", status_id: 2, # verified ) DB[:account_password_hashes].insert( id: account_id, password_hash: BCrypt::Password.create("secret").to_s, ) If the password is stored in a column in the accounts table: account_id = DB[:accounts].insert( email: "name@example.com", password_hash: BCrypt::Password.create("secret").to_s, status_id: 2, # verified ) If you are creating accounts in your tests, you probably want to use the +:cost+ option, otherwise you will have very slow tests: account_id = DB[:accounts].insert( email: "name@example.com", status_id: 2, # verified ) DB[:account_password_hashes].insert( id: account_id, password_hash: BCrypt::Password.create("secret", cost: BCrypt::Engine::MIN_COST).to_s, )
Version data entries
35 entries across 35 versions & 1 rubygems