我有这个index.html.erb文件:
<h3>Pažymiai</h3><br />
Nuo: <%= @begining_of_week = Date.commercial(2011, 48, 1) %>
iki: <%= @end_of_week = Date.commercial(2011, 48, -1) %>
<table class="macs">
<tr>
<th>Vardas, pavardė</th>
<th>Dalykas</th>
<% (@begining_of_week..@end_of_week).each do |d| %>
<th class="calendar"><%= d.day %></th>
<% end %>
</tr>
<% @students.each do |student| %>
<tr>
<td class="name" rowspan="<%= @subjects.count %>"><%=link_to(admin_student_path(student)) do %><%= student.name%><br /> <%= student.surname %><% end %></td>
<% @subjects.each do |subject| %>
<td class="subject"><%=subject.name%></td>
<% (@begining_of_week..@end_of_week).each do |d| %>
<% @mac = Mac.where(:student_id => student.id, :subject_id => subject.id, :date => d) %>
<% if @mac.blank? %>
<td class="calendar_mac" onclick="location.href='<%= new_admin_mac_path %>'"><center>
</center>
<%= link_to 'new_mac', new_admin_mac_path, :remote => true %>
</td>
<% else %>
<% @mac.each do |mac| %>
<td class="calendar_mac" onclick="location.href='<%= edit_admin_mac_path(mac) %>'"><center>
<%= mac.mac%>
<% end %>
<% end %>
</center></td>
<% end %>
</tr>
<% end %>
<% end %>
</table>
如果单元格为空以写入新值,如果单元格有值使其可编辑,如果单击单元格我需要一个弹出窗口,您可以在其中编辑或向数据库添加新元素。我的表看起来: