我需要幫助分配學生批次..他們是在多對多的關係。幫助與rails link_to和發佈方法
<tbody>
<% Batch.all.each do |b|%>
<tr>
<td><%= b.course.name%></td>
<td><%= b.name %></td>
<td><%= b.section_name%></td>
<td><%= link_to "Add", student_batch_students_path(@student, :batch_id=> b.id), :method=> :post%></td>
</tr>
<%end%>
</tbody>
在我的控制器
def create
@batch_student = BatchStudent.new(params[:batch_student])
@batch_student.save
end
我的路線
resources :students do
resources :batch_students
end
resources :batches
但在我的數據庫將其與student_id數據和BATCH_ID爲空
你得到什麼錯誤? – fl00r 2011-04-28 17:11:50
我在原文中增加了更多細節 – ignaciofuentes 2011-04-28 17:12:47
顯示你的'student_batch'動作和你的路線 – fl00r 2011-04-28 17:13:02