rails3 data inserting issues

I am using rails3. when i am trying to insert data into postgrsql got the 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…?

The given error is quite self descriptive: the attribute size limit is 15 characters and you try to assign a longer string to it. Postgres raises an 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 to your model.

String defaults to 255; should you need more characters, you’d better use Text as type.

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