3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

seedデータの入力方法【bcrypt gem追加時】

Posted at

はじめに

seeds.rbでseedデータを投入したいけど
gem bcryptを追加しててモデルにhas_secure_password書いてるなーってとき

入力方法

seeds.rb
User.create
(user_name: 'テストユーザー', 
user_email: 'test@test123', 
password: 'password', 
password_confirmation: 'password', 
created_at: "2019-07-11 02:33:34", 
updated_at: "2019-07-11 02:33:34")

カラムではpassword_digestですが、seeds.rbに書くときは

password: 'password', 
password_confirmation: 'password', 

この二つを指定することで無事パスワードが入力され、ハッシュ化もできました。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?