0

I am trying to seed a db using the gem faker but keep getting:

rails aborted!
NameError: uninitialised constant FAKER

when running rails db:seed

Initially I though it was a problem with my project so I created a new clean one, added gem 'faker' to the Gemfile, ran 'bundle install` but I have the same error.

db/seed.rb

50.times do
  name = FAKER::NAME.name
  Item.create(name: name)
end

I also tried to add require 'faker' to the beginning of the seed.rb file but nothing changed.

I checked all the other answers on Stack Overflow, but they don't seem to solve my problem.

Any idea?

Ruby: 2.4.0p0

Rails: 5.0.1

EDIT: The gem is not installed in the test group as suggested on NameError: uninitialized constant Faker ; Ruby on Rails

Community
  • 1
  • 1
0r4cl3
  • 132
  • 8

0 Answers0