Get the current_index of the my association [closed]

You could use the find_index method for that:

post.comments.pluck(:id).find_index(2)

In this case you would get the index of the comment with id 2.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top