In rails, I wrote a task for automatically generate fake user
task fake_user: :environment do
User.destroy_all
filelink = ""
Dir.glob("#{Rails.root}/public/avatar/admin.jpg").map do |pic|
client = FilestackClient.new('ARz3g0HLfR5i0KuobcdJmz')
filelink = client.upload(filepath: pic)
end
admin = User.create(
email: "admin@example.com",
password: "admin123",
role: 'admin',
name: 'admin',
introduction: FFaker::Lorem::sentence(30),
avatar: filelink.url
)
puts admin.name
20.times do |i|
name = FFaker::Name::first_name
filelink = ""
Dir.glob("#{Rails.root}/public/avatar/user#{i+1}.jpg").map do |pic|
client = FilestackClient.new('ARz3g0HLfR5i0KuobcdJmz')
filelink = client.upload(filepath: pic)
end
user = User.create(
name: name,
email: "#{name}@example.co",
password: "12345678",
introduction: FFaker::Lorem::sentence(30),
avatar: filelink.url
)
user.save!
puts user.name
end
end
And there's no error when running in local.
But when I deploy it to Heroku, some errors happened
Here's the steps I did
Heroku run bundle install
(correct)Heroku run rails db:migrate
(correct)Heroku run rails dev:fake_user
(error...)
Here's the error message I got
Hope someone can help me fix this.... thanks....