after running rake db:reset
i rund rake db:populate and i’m getting this error don’t know where it’s coming from
rake aborted!
undefined method `+' for 4..5:Range
Tasks: TOP => db:populate
(See full trace by running task with --trace)
in my task folder
namespace :db do
desc " Fill database with sample data"
task populate: :environment do
admin = User.create!(name: "Emple User",
email: "exampel@railstuttorial.org",
password: "password",
password_confirmation: "password")
admin.toggle!(:admin)
99.times do |n|
name = Faker::Name.name
email = "example-#{n + 1}@railstutorial.org"
password = "password"
User.create!(name: name, email: email, password: password,
password_confirmation: password)
end
users = User.all(limit: 6)
50.times do
content = Faker::Lorem.sentence(4..5)
users.each { |user| user.microposts.create!(content: content) }
content = nil
end
end
end
You are passing a range to
Faker::Lorem.sentencein your50.timesloop.I’m not sure what you’re trying to achieve but that method is expecting an integer (did you mean 4 or 5?) and when it tries to add something to it within the
Faker::Loremcode it is causing that error.