Reputation: 601
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)
Upvotes: 0
Views: 48
Reputation: 42
Instead of delete use drop :
<%match_results_comfirmation=match_results_comfirmation.drop(1)%>
Here 1 indicates 1st record.
Upvotes: 1