红宝石:红宝石2.0.0p195(2013-05-14修订版40734)[x86_64-darwin12.3.0]
@user = User.find(1)
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
=> #<User id: 1, first_name: "d", last_name: "g", crypted_password: "$2a$10$h4Bil49Pw.bxf0jXvw4mEeYzKh2tgL9kUx/CtBeTg2HB...", salt: "3r3xXr3oqHGP5MpzdxAE", in_games: nil>
我正在加载一个用户,如上图所示。postrges 中 in_games 的数据类型是 integer[] 我不明白为什么会收到错误消息。(如下图)
if @user.in_games.nil?
array = []
@user.in_games = array.push(@game.id)
else
@user.in_games << @game.id
end
@user.save
ActiveRecord::StatementInvalid: PGError: ERROR: array value must start with "{" or dimension information
LINE 1: UPDATE "users" SET "in_games" = '---
^
: UPDATE "users" SET "in_games" = '---