Rails - how to store large numbers like 100000076685963
I need to store large numbers like :100000076685963
Which are t开发者_如何学编程o big for a db field type of integer. In my db migration I use:
t.integer :fb_uid
what field type should I use for large numbers like this?
Thanks
You can use a fixed-point datatype such as decimal with a large precision. Based on the number you've given, a precision of 15 will work but you should figure out exactly what range you are expecting.
t.decimal :fb_fluid, :precision => 15
Try float
t.float :fb_uid
And seems like this is something to do with Facebook (probably facebooker) and assuming these numbers will not use as arithmetic operations, you could probably use just string
t.string :fb_uid
You need to set the limit
field in for the column to get Postgresql's bigint
precision:
t.integer :fb_uid, limit: 8
精彩评论