わかりましたので、学生が利用可能な予定のテーブルから教授との予定を選択できるようにしようとしています。「選択」を押すと、テーブルからすべてのアポイントメント ID が取得され、選択された予定を示すテーブルの最初の番号が表示されます。そのため、予定 ID 5 を選択する代わりに、2、4、5、6 を選択します。次に、選択した予定テーブルに 2 を配置します。私がやりたいことは、私が実際に選択した予定を選択することです。
ここに私の予定_利用可能なビューがあります(必要なコードのみを含めています):
<% @appointment.each do |appointment|%>
<tr>
<td><%= appointment.professor_id %></td>
<td><%= appointment.student_id %></td>
<td><%= appointment.timeslot %></td>
<td><%= link_to 'Choose', :controller => "appointments", :action => "student_edit", :id => @appointment %></td>
</tr>
<% end %>
ここに予定コントローラーがあります(繰り返しますが、すべてのコードがそこにあるわけではありません):
def appointments_available
@appointment = Appointment.find_all_by_student_id("")
end
def student_edit
@appointment = Appointment.find_by_id(params[:id])
@appointment.update_attribute(:student_id, session[:student].user_id)
end
どんな助けでも大歓迎です