Faker: undefined method `[]' for nil:NilClass when using Job.position

Created on 2 Feb 2018  路  3Comments  路  Source: faker-ruby/faker

This line in my seeds file threw an error

position = Faker::Job.position

console error log is

NoMethodError: undefined method []' for nil:NilClass /home/gerry/.rvm/gems/ruby-2.2.6@lapem/bundler/gems/faker-679fd508c9f4/lib/faker.rb:182:inmethod_missing'
/home/gerry/Documents/lapem-cfe/db/seeds/development/users.seeds.rb:15:in `block in evaluate'

Last line and the rest is just part of my application, which unless there's something I'm not considering, probably isn't necessary to post here

BuFixes

All 3 comments

This error occurs when the locale .yml translation file contains no entries for the word.
Faker should default to "en" when there are no entries, but that does not happen here. The code in the "job" class is much simpler than other classes and does not call translate.
One possible quick fix is to include Faker::Config.locale = "en" in your seed if that is acceptable.
Another option is to add entries for jobs to your locale .yml file.

I have created a patch and pull request to fix upstream here: #1142

This PR was merged successfully 馃挴

Was this page helpful?
0 / 5 - 0 ratings

Related issues

huyderman picture huyderman  路  4Comments

ggrillone picture ggrillone  路  6Comments

oyeanuj picture oyeanuj  路  5Comments

vbrazo picture vbrazo  路  3Comments

kevgathuku picture kevgathuku  路  4Comments