当我尝试遍历一个对象数组时,我收到一条非常奇怪的错误消息.错误是
NoMethodError (undefined method `+@' for []:Array):
Run Code Online (Sandbox Code Playgroud)
这是该循环的代码.
#go through items and see if there are any corresponding offers
#All matches are stored in a hash
items.each do |itemsi|
bestoffer = -1
matchescounter++ #matchescounter only get incredmented when all the offers have been taken care of
offers.each do |offs|
if itemsi.togive.to_str == offs.totake.to_str
if offs.togive.to_int > bestoffer
bestoffer = offs.togive.to_int
matches[matchescounter].store(itemi, offer)
end#if
end#if
end#offers loop
end#items loop
Run Code Online (Sandbox Code Playgroud)
我的代码中没有+ @.奇怪
我有一个简单的问题.是否可以从模型中调用控制器方法?如果有可能,我似乎无法弄明白.我应该只是从模型返回控制器而不是尝试直接调用方法吗?谢谢,帕特