rails 项目中 app/helper/****_helper.rb 这是个 module usertimesheetMap = Hash.new entries.each do |entry| usertimesheet = usertimesheetMap[entry.user.id.to_i] if !usertimesheetMap.has_key?(entry.user.id.to_i) usertimesheet = UserTimesheet.new usertimesheetMap[entry.user.id.to_i] = usertimesheet end usertimesheet = usertimesheetMap[entry.user.id.to_i] custom = CustomValue.new custom = custom.get_custom_value_by_userid(entry.user.id.to_i) usertimesheet.hrid= custom.value.to_s usertimesheet.username= entry.user usertimesheet.project= entry.project
class UserTimesheet
def hrid @hrid end
def hrid=(value) @hrid = value end def username @username end
def username=(value) @username = value end
def CWDays @CWDays end
def CWDays=(value) @CWDays = value end
def NWDays @NWDays end
def NWDays=(value) @NWDays = value end
运行结果如下: undefined method `hrid' for #Array:0xb55892b4