Rails3 data inserting issues

I am using rails3. when i am trying to insert data into postgrsql got
error like this

PGError: ERROR: value too long for type character varying(15)

In the migration file have * t.string
:contact_number,:limit=>15,:null=>false*. this string because the
contact_number will be +91 9387292839. Why getting like this…?

El viernes 2 de marzo de 2012 10:35:20 UTC+1, amvis escribi:

The given error is quite self descriptive: the attribute size limit is
characters and you try to assign a longer string to it. Postgres raises
exception instead of just cutting it to 15 characters as mysql(for
instance) would do.

You either shouldnt limit your strings or should add a length validation
your model.
String defaults to 255; should you need more characters, you’d better
Text as type.

Personally, I don’t think its worth to limit strings and save a few
in your db nowadays.

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