Change faker gem phone number format

rafamvc picture rafamvc · Jan 27, 2014 · Viewed 9.6k times · Source

Is there a way to control the format of the Phone number generated by faker?

When I call:

Faker::PhoneNumber.cell_phone.to_i

I end up getting the wrong value.

I also would like to not have extensions.

Answer

zeitnot picture zeitnot · May 13, 2014

You can set custom format on the fly like this:

Faker::Base.numerify('+90(###) ### ####')

This will solve your problem.