0

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)

1 Answer 1

1

Instead of delete use drop :

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

Here 1 indicates 1st record.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.