2015-07-03 130 views
0

我想从活动记录查询结果数组中删除一个条目。
所以我用下面的代码:如何从轨道中的活动记录结果数组中删除记录?

<%match_results_comfirmation=MatchResult.where("challenge_id IN (?)",chllenges_ids)%> 
<%match_results_comfirmation_loop.each do|j|%> 
<%match_results_comfirmation=match_results_comfirmation.delete_at(0)%> 
<%end%> 

这是给一个错误:
未定义的方法`delete_at”为#< MatchResult的:0x00000003a73a48>

然后我用:

<%match_results_comfirmation=MatchResult.where("challenge_id IN (?)",chllenges_ids)%> 
<%match_results_comfirmation_loop.each do|j|%> 
<%match_results_comfirmation=match_results_comfirmation.delete(j)%> 
<%end%> 

但它然后给出了一个错误: 错误的参数数量(1为0)

回答

1

相反删除使用降:

<%match_results_comfirmation=match_results_comfirmation.drop(1)%> 

这里1表示第一个记录。