【发布时间】:2018-07-19 18:30:49
【问题描述】:
在rails中,我写了一个自动生成假用户的任务
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
并且在本地运行时没有错误。
但是当我将它部署到 Heroku 时,发生了一些错误
这是我做的步骤
-
Heroku run bundle install(正确) -
Heroku run rails db:migrate(正确) -
Heroku run rails dev:fake_user(错误...)
这是我收到的错误消息
希望有人能帮我解决这个问题....谢谢....
【问题讨论】:
标签: ruby-on-rails heroku filestack