【发布时间】:2013-07-20 08:27:12
【问题描述】:
在尝试完成这项工作大约 12 小时后,我不得不求助于 SO 寻求救赎。这是场景。
我正在使用 zurb Foundation 4,并试图在我的仪表板中为嵌套资源创建一个显示模式 ajax 表单。
我有以下嵌套资源:
resources :lessons, only: [:index, :edit, :show] do
resources :notes, only: [:new, :create, :edit, :delete]
end
在课程/1/notes/new 中的表格可以正常工作。
我的 static_pages/home 上有一个表格,如下所示:
<table>
<thead>
<tr>
<th>Student</th>
<th>Subject</th>
</tr>
</thead>
<% @lessons.each do |lesson| %>
<tr>
<td><%= link_to lesson.student.name, lesson %></td>
<td><%= lesson.subject.name %></td>
<td><%= link_to 'make a note', new_lesson_note_path(lesson), "data-reveal-id"=>"note-for" %></td>
</tr>
<% end %>
在我的所有标记下,我在基础显示模式中有以下形式:
<!--Reveal Form-->
<div id="note-for" class="reveal-modal">
<% @lessons.each do |lesson| %> <--form now associated with proper object-->
<%= form_for Note.new, :url => new_lesson_note_path(lesson) do |f| %>
<div class="field">
<%= f.label :content %>
<%= f.text_area :content %>
</div>
<div class="actions">
<%= f.submit "Save", class: "small button"%>
</div>
<% end %>
<a class="close-reveal-modal">×</a>
<% end %>
</div>
模态渲染很好,但是提交表单会引发以下错误:
No route matches [POST] "/lessons/1/notes/new"
我在这里很茫然,请帮忙。
【问题讨论】:
标签: ruby-on-rails forms routing zurb-foundation nested-resources