【发布时间】:2019-08-27 23:22:55
【问题描述】:
Rails 5.2.3
MySQL 8 server with MySQL gem
我的迁移工作正常:
def change
add_column :users, :roles, :json
end
记录在用户表中创建为 JSON。我遇到的问题是种子文件。
来自种子文件:
users = [
{'email':"john@acme.net", 'first_name': "John", 'last_name': "Doe", 'status':'active', 'roles':"['admin']", 'password': "12345678", 'password_confirmation': "12345678"}
]
users.each do |user|
User.create!(user) if User.find_by_email(user[:email]).nil?
end
当我运行 rake 时,出现以下错误:
ActiveModel::RangeError: 1566947904332768 is out of range for ActiveModel::Type::Integer with limit 4 bytes
/db/seeds.rb:9:in `block in <main>'
/db/seeds.rb:8:in `each'
/db/seeds.rb:8:in `<main>'
/bin/rails:9:in `<top (required)>'
/bin/spring:15:in `<main>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
Process finished with exit code 1
我也试过了:
'roles':['admin']
同样的错误。有什么想法吗?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-5.2 mysql-8.0