0
第一次使用DataMapper。我已经在MySQL数据库中建立了一个表,并连接到这个表。我已经定义下面的映射:使用DataMapper获取记录
class Track_Scan
include DataMapper::Resource
property :item_id, Integer
property :current_station_id, Integer
property :next_station_id, Integer
end
它返回的项目的右侧数 - 例如如果有五个记录在数据库中的一个给定的ID,Track_Scan.all(:item_id => my_id)
将产生一组五个对象的 - 但是当我呼吁每一个在此,我看到了相同的对象五次:
#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>
#<Track_Scan:0x7fcbcfca59c0>
,而不是五个不同的对象他们在current_station_id
和next_station_id
中有不同的值,正如它们在表中实际做的那样。
任何帮助?