Giter Club home page Giter Club logo

Comments (29)

stympy avatar stympy commented on May 19, 2024

I just released 0.9.1 which doesn't stomp on the default locale any more. I'll have to take a longer look at the failing test issue.

from faker.

stympy avatar stympy commented on May 19, 2024

And now 0.9.2 is out. :) This version stops clobbering the load path, which may have been the test problem.

from faker.

morgoth avatar morgoth commented on May 19, 2024

Now is working fine.
Thanks.

from faker.

sporkd avatar sporkd commented on May 19, 2024

Just got the ripple effect from this. Thanks for the quick fix!

from faker.

rafaelfranca avatar rafaelfranca commented on May 19, 2024

It's not working for me. The default locale of application don't work in test environment in the 0.9.2 version. The gem change the locale for 'en' and my default locale is 'pt_BR'

from faker.

stympy avatar stympy commented on May 19, 2024

rafael, perhaps you could put together a sample app that shows the problem?

from faker.

rafaelfranca avatar rafaelfranca commented on May 19, 2024

Sure! It's here: https://github.com/rafaelfranca/faker_test

from faker.

stympy avatar stympy commented on May 19, 2024

rafael, I just pushed some changes that should fix the problem for you (the test app now passes the tests). Also, note the change in the readme about setting locale in Rails.

from faker.

rafaelfranca avatar rafaelfranca commented on May 19, 2024

Nice! Thanks.

from faker.

lgrains avatar lgrains commented on May 19, 2024

I'm seeing more of these types of errors:

=> nil
ruby-1.9.2-p136 :003 > Factory(:merchant)
NoMethodError: private method rand' called for "translation missing: en.faker.name.last_name":String from /Users/lrains/.rvm/gems/ruby-1.9.2-p136@hazzoo/gems/faker-0.9.5/lib/faker.rb:37:infetch'
from /Users/lrains/.rvm/gems/ruby-1.9.2-p136@hazzoo/gems/faker-0.9.5/lib/faker/name.rb:10:in last_name' from /Users/lrains/.rvm/gems/ruby-1.9.2-p136@hazzoo/gems/faker-0.9.5/lib/faker/company.rb:35:inblock

I'm running Rails 3, ruby 1.9.2, and faker 0.9.5. This only happens in Rails Console. It's working fine inside my application.

from faker.

roberthead avatar roberthead commented on May 19, 2024

I'm having the same problem as lgrains.

from faker.

marklocklear avatar marklocklear commented on May 19, 2024

I was having problems running faker on Heroku. The error I was getting was was: rake task error is: private method `rand' called for "translation missing: en.faker.address.street_address":String

I was able to fix this by adding the faker version of the locals/en.yml to my heroku repo.

from faker.

agenteo avatar agenteo commented on May 19, 2024

same problem as Igrains here, with

private method `rand' called for "translation missing: en.faker.name.first_name":String

faker 0.9.5 (testing a Radiant 0.9.1 extension with rspec 1.1.12)
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin10.7.0]

from faker.

rubiety avatar rubiety commented on May 19, 2024

Just wanted to comment that I was still running into an issue with this myself with faker 0.9.5. I fixed it by explicitly telling I18n to reload after requiring "faker" in my spec_helper.rb:

I18n.reload!

For my app, I believe this was because a translation was accessed in an initializer before faker was required. This probably means that I18n loaded everything in the I18n.load_path before faker added to the load path. So even though faker is adding to the load path, it is not forcing a reload of I18n. In most cases this is fine (as in, when no translations are accessed before faker is required), but in my case it was not.

@stympy It may be worthwhile forcing an I18n reload after you modify the load_path in the gem anyways; this is probably good practice, just in case.

from faker.

maca avatar maca commented on May 19, 2024

Same issue here: private method `rand' called for "translation missing: pt-BR.faker.address.street_address":ActiveSupport::SafeBuffer

Whats the fix?

from faker.

rubiety avatar rubiety commented on May 19, 2024

@maca Check out my last comment - until this is done within the faker gem, you should call this immediately after requiring faker in your spec_helper.rb:

I18n.reload!

from faker.

maca avatar maca commented on May 19, 2024

Thanks it did the trick, I tried before

I had to add gem 'faker', :require => nil to my Gemfile

and manually requiring in spec_helper, in the line below I added I18n.reload!

from faker.

stympy avatar stympy commented on May 19, 2024

@rubiety, thanks for the tip - I have pushed this change. if you and @maca could try it out and let me know if it works for you, I'll push a new gem.

Thanks!

from faker.

maca avatar maca commented on May 19, 2024

Hi, I used your last pull with no luck.

I still have to manually require faker in my spec_helper instead of using the Gemfile and do the I18n reload.

from faker.

maca avatar maca commented on May 19, 2024

It actually works for rspec but not for cucumber

my env.rb:

       require 'cucumber/rails'
       require 'faker'

       I18n.reload!

       Dir[Rails.root.join("test/factories/**/*.rb")].each {|f| require f}
       ...

from faker.

maca avatar maca commented on May 19, 2024

Had to switch back to 0.3.1 and ignore deprecation warnings for #returning

from faker.

haarts avatar haarts commented on May 19, 2024

I still have this issue.

from faker.

JonKernPA avatar JonKernPA commented on May 19, 2024

@rubiety thanks for preserving the hair on my head... I spent 30 minutes wondering WTF was going on with Faker inside my FactoryGirl stuff for errors like this:

private method `rand' called for "translation missing: en.faker.name.first_name"

and your tip worked like a charm!

require 'factory_girl'
require 'faker'
I18n.reload!  # <== Thanks @rubiety

I also had to do this in environment.rb:

config.i18n.default_locale = :en

or you can do this:

config.i18n.locale = :en

from faker.

hoblin avatar hoblin commented on May 19, 2024

Still have this issue. It appears on Jenkins builds.
I18n.reload! not helps
https://gist.github.com/1041713
Rails 2.3.8
Ruby 1.8.7 p334 (RVM)
Feel free to ask additional info

from faker.

cimm avatar cimm commented on May 19, 2024

Pulling the gem from github after commit 22a9476 fixed it for me (Rails 3.1 and Ruby 1.9.2). Thanks!

from faker.

hoblin avatar hoblin commented on May 19, 2024

I'm switch to ffaker gem =)

from faker.

mulderp avatar mulderp commented on May 19, 2024

I am also setting in config/application.rb

config.i18n.locale = :de

Because I still see a problem that :en locale is taken as default with ruby 1.8.7, Rails 3.0.10 Faker 1.0

from faker.

simicic avatar simicic commented on May 19, 2024

Setting :en for me was not an option and switching to ffaker worked out well, if someone else still has this issue...

from faker.

lreardon avatar lreardon commented on May 19, 2024

FWIW I was running into the same issue and none of the above workarounds were, well, working.

In my case, I was just not calling the right method. Eg. I was calling Faker::Name.firstname, but the actual method is Faker::Name.first_name. Take care of snake-case in method names!

from faker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.