The filler does not load an ActiveRecord instance; therefore, any checks, callbacks, built-in methods will not work. Instead, it loads its own Record object, using column attributes and pure SQL to improve performance.
On the other hand, Devise does not create a password column, it creates an encrypted_password column and runs all the logic behind the scene, check this link if you want to get an idea of โโcode development.
Solution: we need to call password_digest to encrypt this password, and then set encrypted_password directly, but this method is protected and cannot be called inside the rake. Instead, we will use the โnewโ method to run password_digest, so your code will look something like this:
password = "password" User.populate 20 do |user| user.name = Faker::Name.name user.email = Faker::Internet.email user.encrypted_password = User.new(:password => password).encrypted_password
source share