You can set custom format on the fly like this:
Faker::Base.numerify('+90(###) ### ####')
This will solve your problem.
Question
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.
Solution
You can set custom format on the fly like this:
Faker::Base.numerify('+90(###) ### ####')
This will solve your problem.
OTHER TIPS
Faker::PhoneNumber.cell_phone
is basically just calling numerify
with one of the predefined phone_number_formats
.
So you could just use numerify
with your own format. For e.g. If you want 10 digits number, you would do:
Faker.numerify('#########')
If you'd still like to use Faker::PhoneNumber.cell_phone
but would like to get rid of the hyphens, you could use gsub
to replace the hyphens as:
Faker::PhoneNumber.cell_phone.gsub(/-/, '')