我正在尝试将数据插入 ROR
中的数据库,对于电话号码,我采用了字段整数..但它只采用了 9 位数字..如果我尝试输入 10 位数字。它提供错误作为。
Mysql2::Error: Out of range value for column 'Telephone' at row 1:
INSERT INTO contacts (
Email,
Message,
NAME,
SUBJECT,
Telephone,
created_at,
updated_at
)
VALUES
(
'ghfghf',
'daaswwd ffdd',
'ghfghf',
'fggfhg',
9234567899,
'2016-07-27 05:47:43',
'2016-07-27 05:47:43'
)
但是,如果我将数字作为 1234567890
..它会正确插入数据,但不会插入任何其他数字.. 9878675645
最佳答案
Mysql2::Error: Out of range value for column 'Telephone' at row 1:
将 telephone
的列类型更改为字符串,因为整数不支持那么长的范围
def up
change_column :contacts, :telephone, :string
end
def down
change_column :contacts, :telephone, :integer
end
关于mysql - ROR 中的联系电话文本字段表单错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38604683/