当在 rails 控制台中执行命令y Grau.all
时,我得到这些奇怪!binary
的字符串而不是属性的名称。知道如何解决这个问题吗?
谢谢。
irb(main):003:0> y Grau.all
←[1m←[36mGrau Load (0.0ms)←[0m ←[1mSELECT "graus".* FROM "gr
←[1m←[35mEXPLAIN (0.0ms)←[0m EXPLAIN QUERY PLAN SELECT "grau
EXPLAIN for: SELECT "graus".* FROM "graus"
0|0|0|SCAN TABLE graus (~1000000 rows)
---
- !ruby/object:Grau
attributes:
!binary "aWQ=": 27
!binary "bm9tZQ==": 1 Grau
!binary "Y3JlYXRlZF9hdA==": 2012-04-06 21:24:34.553163000 Z
!binary "dXBkYXRlZF9hdA==": 2012-04-06 21:24:34.553163000 Z
- !ruby/object:Grau
attributes:
!binary "aWQ=": 28
!binary "bm9tZQ==": 2 Grau
!binary "Y3JlYXRlZF9hdA==": 2012-04-06 21:24:34.599963000 Z
!binary "dXBkYXRlZF9hdA==": 2012-04-06 21:24:34.599963000 Z
[更新]
irb(main):001:0> Grau.find(1)
←[1m←[36mGrau Load (43.8ms)←[0m ←[1mSELECT "graus".* FROM "graus" WHERE "grau
s"."id" = ? LIMIT 1←[0m [["id", 1]]
=> #<Grau id: 1, nome: "1º Grau", created_at: "2012-04-11 15:51:32", updated_at:
"2012-04-11 15:51:32">
irb(main):002:0>
我在 Windows 7 64 位上使用 Rails 3.2.3、Ruby 1.9.3。