Search code examples
ruby-on-railsfaker

Rails faker in model files?


So i've used faker before, but im making a sort of stress test model method to be able to insert n amount of fake records for a model to test things.

However despite requiring faker in that particular model file I always get the error LoadError: cannot load such file -- faker. Is it not possible to use faker in model files?

Thanks!


Solution

  • You may want to check

    require 'faker'
    I18n.reload!
    

    People are claining it sometimes does the trick https://github.com/stympy/faker/issues/278