teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ビューの追加

2020/05/30 12:35

投稿

kawa0tatsu
kawa0tatsu

スコア7

title CHANGED
File without changes
body CHANGED
@@ -65,6 +65,52 @@
65
65
      @post.recordings.order("recordings + sort_column+  ' ' + sort_direction")
66
66
      @instruments = @post.instruments.order('created_at desc')
67
67
    end
68
+
69
+ ビュー(show.html.erb)
70
+
71
+ <table>
72
+
73
+ <tr><%# Start of th %>
74
+ <% @instruments.each do |instrument| %>%# Start of instruments th %><%# 楽曲編成に応じてカラムを追加 %>
75
+ <% if instrument.name.include? 'orchestra' %><%# 管弦楽曲の場合、指揮者カラムを追加 %>
76
+ <th><%= sortable "conductor", "Conductor" %></th>
77
+ <% end %>
78
+
79
+ <% if instrument.name.include? "#{instrument.name}" %>
80
+ <th><%= sortable "#{instrument.name}","#{instrument.name}" %></th>
81
+ <% end %>
82
+ <% end %><%# End of instruments th %>
83
+
84
+ <% (1..@post.mov).each do |movnum| %><%# 楽章数に応じてカラム数が変化 %>
85
+ <th width="70"><%= sortable "Mov#{movnum}" %></th>
86
+ <% end %>
87
+ </tr><%# End of th %>
88
+
89
+
90
+ <% @post.recordings.each do |recording| %>
91
+
92
+ <tr>
93
+ <% @instruments.each do |instrument| %>
94
+
95
+ <% if instrument.name.include? 'orchestra' %>
96
+ <td><%= recording.conductor %></td>
97
+ <% end %>
98
+
99
+ <% if instrument.name.include? "#{instrument.name}" %>
100
+ <td><%=recording.send("#{instrument.name}") %></td>
101
+ <% end %>
102
+
103
+ <% end %><%# End of the loop of instruments %>
104
+
105
+ <% recording.durations.each do |duration| %><%# 楽章ごとの演奏時間 %>
106
+ <td><%=Time.at(duration.total_seconds).utc.strftime("%M:%S") %></td>
107
+ <% end %><%# End of durations %>
108
+
109
+ </tr>
110
+
111
+ <% end %><%# End of the loop of each recordings %>
112
+
113
+ </table>
68
114
  ```
69
115
 
70
116
  ### 試したこと