Validation on phone number

Hi,
i have column name phone with integer datatype but when i enter phone
number it throws an error
“1325565488 is out of range for ActiveRecord::Type::Integer with limit
4”

i have changed limit to 8 in migration file but still it didn’t work.

Any kind suggestions would be appreciated. Thanks

Use a string.

–Rob
Sent from my cell, please excuse any typos.

Use string where??? i’m just a beginner so can u tell me that in detail

On 24 March 2016 at 21:54, Ramu G. [email protected] wrote:

Use string where??? i’m just a beginner so can u tell me that in detail

As the datatype for the column in the database.

Colin

Use a string data type for the number.

–Rob
Sent from my cell, please excuse any typos.

Ramu G. wrote in post #1182441:

Hi,
i have column name phone with integer datatype but when i enter phone
number it throws an error
“1325565488 is out of range for ActiveRecord::Type::Integer with limit
4”

goto your db folder and in the migration change the phone number field
data type from integer to string. and thats all. but u will will to do
rake db:migrate
after that.

On 26 March 2016 at 09:25, Naveed A. [email protected] wrote:

after that.
It is best to add a new migration to do this.

Colin

On Sat, Mar 26, 2016 at 4:35 AM, Colin L. [email protected] wrote:

rake db:migrate
after that.

It is best to add a new migration to do this.

Colin

((this is what I tried to send))

Agreed. If you change an old migration, and run rake db:migrate
NOTHING
will happen, because that migration is already saved in the database
table
‘schema_migrations’. You either need to create a new migration, or you
have
to drop the data base and re-run all the migrations.

I once tried to circumvent this in a panic situation by deleting the
schema
migration record and re-running the migration, but it was such a crazy
thing to try, I gave up.

My advice is to do just as Colin suggested, and use a new migration to
change the table.

On 26 March 2016 at 14:37, tamouse pontiki [email protected]
wrote:

Sorry if this was duplicated – I was trying to use Apple Mail again after
all these years and suddenly remembered why I wasn’t using it.

Hi Tamouse, I don’t think we received it once, let alone twice. At
least I did not see it.

Colin

Sorry if this was duplicated – I was trying to use Apple Mail again
after
all these years and suddenly remembered why I wasn’t using it.

On Sat, Mar 26, 2016 at 9:34 AM, tamouse pontiki
[email protected]

"1325565488 is out of range for ActiveRecord::Type::Integer with limit

((this is what I tried to send))

Agreed. If you change an old migration, and run rake db:migrate NOTHING will
happen, because that migration is already saved in the database table
‘schema_migrations’. You either need to create a new migration, or you have to
drop the data base and re-run all the migrations.

I once tried to circumvent this in a panic situation by deleting the schema
migration record and re-running the migration, but it was such a crazy thing to
try, I gave up.

My advice is to do just as Colin suggested, and use a new migration to change
the table.

It’s helpful to think of migrations as “version control for your
database”. They capture the steps along the way to where you are now
(the schema.rb is the current state, or HEAD, of your migrations).

Walter

Thank u guys a lot! It helped me

I had similar kind of problems, but unfortunately nothing helped me. I even wrote on the forums and did not find the correct answer for this. But I also had such a problem that I wanted to create accounts on some sites, but I needed a confirmation with a mobile number, and I did not want to show my mobile phone to different sites, because I am doing business. So I decided to google what to do in this situation and came across VerifyWithSMS . And now, using this service, I create any accounts on any sites without a mobile number :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs