I want to delete one entry from an array of active record query result.
So I used following code :
<%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%>
This is giving an error :
undefined method `delete_at' for #< MatchResult:0x00000003a73a48>
Then I used:
<%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%>
But then it is giving an error : wrong number of arguments (1 for 0)
Instead of delete use drop :
<%match_results_comfirmation=match_results_comfirmation.drop(1)%>
Here 1 indicates 1st record.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.