我正在使用 publicactivity gem 来审核我的应用程序中的活动。
使用 MongoDB,下面的数据都不是真实的 - 但代表真实数据。
我推了一些这样的数据:
"changes" : [
{
"oldFirst" : "Aaron2",
"oldLast" : "Aardvark2",
"oldCity_id" : "Bogota, TN",
"oldZip_code" : 38007,
"oldPhone" : [
"9993339999",
"4442224443"
],
"oldStreet1" : "1111 Brighton Clopton St",
"oldStreet2" : "Suite 100",
"oldEmail" : [
"uk@tel.com"
],
"oldType" : "customer",
"oldLatitude" : "36.1625531",
"oldLongitude" : "-89.4362431",
"oldCust_notes" : "",
"oldAccount_id" : ""
},
{
"newFirst" : "Aaron",
"newLast" : "Aardvark",
"newCity_id" : "Brighton, TN",
"newZip_code" : 38011,
"newPhone" : [
"9993338888",
"4442223334"
],
"newStreet1" : "1111 Brighton Clopton Dr.",
"newStreet2" : "",
"newEmail" : [
"uk@tel.com"
],
"newType" : "customer",
"newLatitude" : "35.4558615",
"newLongitude" : "-89.68162079999999",
"newCust_notes" : "",
"newAccount_id" : ""
}
]
那么我该如何谈论这些元素呢?
我试过了:
<%= activity.changes[0]["oldFirst"] %>
<%= activity.changes["oldFirst"] %>
<%= activity.changes.oldFirst %>
<% if activity.changes.any?
activity.changes.each do |c|
%>
<%= c["oldfirst"] %>
<%end%>
<%end%>
等等
我不断尝试我所知道的组合 - 我得到了这个:
no implicit conversion of String into Integer
串成整数?!怎么回事?这都是字符串类型的数据,我试图将其作为字符串类型的数据访问——我不明白为什么它认为我拥有或想要整数值。
我可以帮忙吗?