[英]Is it possible to seed users into the DB with the Clearance gem?
我正在使用 Clearance gem 進行身份驗證的 Ruby-on-Rails 項目。 有沒有辦法使用seeds.rb 文件將用戶播種到我的數據庫中,或者我是否必須在登錄頁面上手動創建用戶? 看起來用戶表是用加密密碼屬性構造的,所以我不確定如何進行播種。
文檔並沒有說你必須做任何花哨的事情。
def create_user(email)
User.create!(
email: email,
password: "password1234"
)
end
#fake users
1...50.times do |i|
create_user("person_#{i}@test#{i}.io")
end
User.last
=> <User id: 50, created_at: "2018-05-31 18:51:57", updated_at: "2018-05-31 18:51:57", email: "person_49@test49.io", encrypted_password: "$2a$10$JBWpdFocyd1TTBy5W30uYuWaD5nTo1TPErtQpt2nNZO...", confirmation_token: nil, remember_token: "cfaf107ea30d3303bb991f61973368b2a1fd44c7">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.