validation on phone number

65 views
Skip to first unread message

Ramu Goud

unread,
Mar 24, 2016, 5:49:36 PM3/24/16
to rubyonra...@googlegroups.com
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

--
Posted via http://www.ruby-forum.com/.

Robby O'Connor

unread,
Mar 24, 2016, 5:51:21 PM3/24/16
to rubyonra...@googlegroups.com

Use a string.

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ffb4a1a1018546058e1a326469ef73b8%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ramu Goud

unread,
Mar 24, 2016, 5:55:24 PM3/24/16
to rubyonra...@googlegroups.com
Use string where???? i'm just a beginner so can u tell me that in detail

Colin Law

unread,
Mar 24, 2016, 5:59:38 PM3/24/16
to Ruby on Rails: Talk
On 24 March 2016 at 21:54, Ramu Goud <li...@ruby-forum.com> 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

Robby O'Connor

unread,
Mar 24, 2016, 6:00:27 PM3/24/16
to rubyonra...@googlegroups.com

Use a string data type for the number.

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Naveed Alam

unread,
Mar 26, 2016, 5:26:36 AM3/26/16
to rubyonra...@googlegroups.com
Ramu Goud 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.

Colin Law

unread,
Mar 26, 2016, 5:36:56 AM3/26/16
to Ruby on Rails: Talk
It is best to add a new migration to do this.

Colin

tamouse pontiki

unread,
Mar 26, 2016, 10:38:14 AM3/26/16
to rubyonra...@googlegroups.com
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 <tamous...@gmail.com> wrote:


Colin Law

unread,
Mar 26, 2016, 10:56:52 AM3/26/16
to Ruby on Rails: Talk
On 26 March 2016 at 14:37, tamouse pontiki <tamous...@gmail.com> 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

tamouse pontiki

unread,
Mar 26, 2016, 11:37:14 PM3/26/16
to rubyonra...@googlegroups.com
((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. 

Walter Lee Davis

unread,
Mar 27, 2016, 7:55:40 AM3/27/16
to rubyonra...@googlegroups.com
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

>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHUC_t8cNyiPPnyp%2B6jceSFCS%2BOBgT1L%3Dw5fDKJSUe9E4XKDMA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages