名前、日付、スコア、グレードの 4 つの列を持つテーブルを設定しました。表全体で、名前カテゴリに多くの重複があります。名前をクリックすると、そのユーザーのすべてのスコア、グレード、およびそれぞれの日付が表示されます。
現在、テーブルに複数回表示される名前をクリックすると、選択したインスタンスのスコア、グレード、および日付のみが表示されます。その名前に関連付けられているすべてのスコア、グレード、および日付を表示するにはどうすればよいですか。
ここにデータベースのスナップショットがあります -
スコア表:
class CreateScores < ActiveRecord::Migration
def change
create_table :scores do |t|
t.string :name
t.integer :score
t.date :fielded
t.string :grade
t.integer :name_id
t.timestamps
end
end
end
生徒のテーブル:
class CreateStudents < ActiveRecord::Migration
def change
create_table :students do |t|
t.integer :id
t.string :name
t.timestamps
end
end
end
これが私のビューに表示されるテーブルです-
<% @score.each do |score| %>
<tr class="tableline" >
<td class="tableline"><%= link_to score.name.upcase, score, {style: 'color:#FFFFFF; text-decoration: none; opacity:1'} %></td>
<td class="tableline"><%= score.fielded %></td>
<td class="tableline"><%= score.score %></td>
<td class="tableline"><%= score.grade %></td>
</tr>
<% end %>