Skip to content
New issue

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

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

Already on GitHub? # to your account

fetch_all raises error #1200

Closed
kevinburkeomg opened this issue May 3, 2018 · 7 comments
Closed

fetch_all raises error #1200

kevinburkeomg opened this issue May 3, 2018 · 7 comments

Comments

@kevinburkeomg
Copy link

I'm trying to determine the total number of possible entries for Faker::Name.first_name. Running the following:

bin/rails console
require 'faker'
Faker::Name.fetch_all :first_name

yields the following error:

[17] pry(main)> Faker::Name.fetch_all 'first_name'
I18n::MissingTranslationData: translation missing: en.faker.first_name
from /Users/kevin.burke/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/i18n-0.8.6/lib/i18n.rb:311:in `handle_exception'

Per #811, I tried I18n.reload!, but that had no effect. I also tried hardcoding the locale to en and that did not work either.

I'm using Faker 1.7.3 and Ruby 2.4.3, on a Mac. I can provide more debugging information as necessary, but I am not sure what I am looking for.

If there is a different way to compute the total number of possibilities for a value, let me know.

@JonathanWThom
Copy link
Contributor

@kevinburkeomg Give this a shot:

Faker::Base.fetch_all("name.first_name")

I don't have enough knowledge of the library to know if the syntax you posted above should work (it's certainly a nice way to write things though). It failed on a few other classes I tried, so maybe it's just not supported. I would be happy to work on a PR to fix/add that behavior if that's wanted by the maintainers though.

@vbrazo
Copy link
Member

vbrazo commented May 19, 2018

@JonathanWThom exactly. You could do:

Faker::Base.fetch_all("name.first_name") or Faker::Name.fetch_all("name.first_name").

I personally prefer to use the Base class.

@vbrazo vbrazo closed this as completed May 19, 2018
@kevinburkeomg
Copy link
Author

It seems at the very least like the error message could be clearer.

@vbrazo
Copy link
Member

vbrazo commented May 21, 2018

Wanna work on this improvement? @kevinburkeomg

@stympy
Copy link
Contributor

stympy commented May 21, 2018

I don't think there's anything to work on here... we don't advertise fetch_all as a public API.

@kevinburkeomg
Copy link
Author

Maybe then documenting how to retrieve all of the options for a given function, besides in a comment to a closed issue

@stympy
Copy link
Contributor

stympy commented May 21, 2018

Ok, well, if a PR shows up, we'll review it. :)

I'd need to see a compelling argument, though, if a PR encouraged the use of internal functions like fetch_all for public consumption.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants