フォームからレコードを作成しようとしています。Railscast 136 を下地処理として使用しました。送信しようとすると、欠落している部分に対して 500 エラーが発生します。コントローラーに関連付けられた JavaScript ビューを作成しましたが、モデルと同じ名前のビューを要求しています。
エラーメッセージ
レンダリングされた予定/create.js.erb (3.8 ミリ秒) 12 ミリ秒で 500 内部サーバー エラーを完了
ActionView::Template::Error ({:locale=>[:en]、:formats=>[:js、:html]、:handlers=>[:erb、:builder、:coffee] で部分的な予定/予定がありません}. 検索対象: * "/Users/gjores/Sites/Rails/verkstad_test/app/views" ): 1: $('#appointments').append('<%= j render(@appointment) %>') ; app/views/appointments/create.js.erb:1:in
_app_views_appointments_create_js_erb___2325925946390315228_70273089113920' app/controllers/appointments_controller.rb:16:in
create'
コントローラ
def create
@appointment = Appointment.new(params[:appointment])
if @appointment.save
respond_to do |format|
format.html { redirect_to new_appointment_path, :notice => "Successfully created appointment." }
format.js
end
else
render :action => 'new'
end
end
予定/new.html.erb
<div id="appointments">
<%= render 'shared/appointment_part' %>
</div>
<% title "New Appointment" %>
<table>
<% @students.each do |s| %>
<%= form_for @appointment, :remote => true do |f|%>
<%= f.error_messages %>
<tr>
<td><%= s.name %></td>
<td><%= f.label :week %></td>
<td><%= f.number_field :week %></td>
<td><%= f.label :teacher_id %></td>
<td><%= f.collection_select(:teacher_id, Teacher.all, :id, :name) %></td>
<%= f.hidden_field :student_id, :value => s.id %>
<td><%= f.submit %></td>
</tr>
<% end %>
<% end -%>
</table>
<p><%= link_to "Back to List", appointments_path %></p>
予定/create.js.erb
$('#appointments').append('<%= j render(@appointment) %>');
ルート
appointments GET /appointments(.:format) appointments#index
POST /appointments(.:format) appointments#create
new_appointment GET /appointments/new(.:format) appointments#new
edit_appointment GET /appointments/:id/edit(.:format) appointments#edit
appointment GET /appointments/:id(.:format) appointments#show
PUT /appointments/:id(.:format) appointments#update
DELETE /appointments/:id(.:format) appointments#destroy
teachers GET /teachers(.:format) teachers#index
POST /teachers(.:format) teachers#create
new_teacher GET /teachers/new(.:format) teachers#new
edit_teacher GET /teachers/:id/edit(.:format) teachers#edit
teacher GET /teachers/:id(.:format) teachers#show
PUT /teachers/:id(.:format) teachers#update
DELETE /teachers/:id(.:format) teachers#destroy
notice_students POST /students/notice(.:format) students#notice
students GET /students(.:format) students#index
POST /students(.:format) students#create
new_student GET /students/new(.:format) students#new
edit_student GET /students/:id/edit(.:format) students#edit
student GET /students/:id(.:format) students#show
PUT /students/:id(.:format) students#update
DELETE /students/:id(.:format) students#destroy