我正在阅读 Michael Hartl 的教程,但没有收到错误消息:
undefined local variable or method `n' for main:Object
当我跑步时bundle exec rake db:populate
sample_data.rake 文件
namespace :db do
desc "Fill database with sample data"
task populate: :environment do
name = Faker::Name.name
email = "example-#{n+1}@railstutorial.org"
password = "password"
User.create!(name: name,
email: email,
password: password,
password_confirmation: password)
end
end