Home>

In a database like the image below, 18 records are grouped (round_id), and if there is even one nil in the hole_score in it, the course of that record is acquired and all are tried to be retrieved by each do.

@now_playing = Score.where ("hole_score is NULL"). Distinct.pluck (: round_id)
<% @ now_playing.each do | a |%>
<% = link_to a, round_play_path (course: a, round_id: a)%><br>
<% end%>


At present, I can output the one without duplication, but I can only display round_id.
It may be natural because it is written as .pluck (: round_id) ...
What we want to achieve is a golf list of rounds with no score entered.
Thank you.

* Currently, I want to make a list of round_ids like ↑, which is a course.

  • Answer # 1

    @now_playing = Score.where (user_id: current_user) .where ("hole_score is NULL"). Distinct (: round_id) .pluck (: round_id,: course)