In my development and test environments, I want to seed the database with a bunch of users. I\'m using Ruby on Rails v3.2.8 and the latest Devise. So I added this line in
I don't know if it may help but actually I'm doing this to create a default Admin user in my Rails 5 app but without sharing the password in plain text in my GitHub repository.
Basically the logic for this is:
So in the db/seeds.rb
append this:
randomPassword = Devise.friendly_token.first(8)
mainAdminUser = Admin.create!(email: "me@gmail.com", password: randomPassword, name: "Username")
And if you are using devise confirmable
feature just skip confirmable option by doing this:
mainAdminUser = Admin.new(
email: "me@gmail.com",
password: randomPassword,
password_confirmation: randomPassword,
name: "Username"
)
mainAdminUser.skip_confirmation!
mainAdminUser.save!
And your good to go!
Now you have a default user but you are not sharing a default password! I hope it could be useful for somebody.