我正在构建一个基于 Sinatra 的 API,我看到我的用户模型有一些奇怪的响应。每个响应都会返回一个包含空值的集合。其他型号按预期返回。
irb(main):018:0> User
=> User(id: integer, email: string, username: string, created_at: datetime, updated_at: datetime)
irb(main):019:0> User.find(1)
D, [2014-01-31T18:31:38.488743 #50624] DEBUG -- : User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
=> #<User id: 1, email: "test@example.com", username: "tyler", created_at: "2014-01-30 01:55:16", updated_at: "2014-01-30 01:55:16">
irb(main):020:0> User.find(1).to_json
D, [2014-01-31T18:32:18.079096 #50624] DEBUG -- : User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
=> "{\"id\":null,\"email\":null,\"username\":null,\"created_at\":null,\"updated_at\":null}"