Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gerryhd opened this issue Feb 2, 2018 · 3 comments
Closed

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

gerryhd opened this issue Feb 2, 2018 · 3 comments

Comments

@gerryhd
Copy link

gerryhd commented Feb 2, 2018

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:in method_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

@PuZZleDucK
Copy link
Contributor

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.

PuZZleDucK added a commit to PuZZleDucK/faker that referenced this issue Feb 6, 2018
@PuZZleDucK
Copy link
Contributor

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

vbrazo pushed a commit that referenced this issue May 17, 2018
* update rake

* add failing test for locale without translations

* add fetch for position fixing #1139

* reformat class to make consistant with other Faker classes
@vbrazo
Copy link
Member

vbrazo commented May 17, 2018

This PR was merged successfully 💯

@vbrazo vbrazo closed this as completed May 17, 2018
davidmorton0 pushed a commit to davidmorton0/faker that referenced this issue Jul 12, 2021
* update rake

* add failing test for locale without translations

* add fetch for position fixing faker-ruby#1139

* reformat class to make consistant with other Faker classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants