我已經寫了一些partials,但他們似乎並沒有渲染。其他一些報告過相同問題的海報錯誤地使用了<%...%>嵌入的ruby代碼,而不是<%= ...%>。我沒有犯這個錯誤,所以我不確定爲什麼我的部分不是渲染。也許有人會在我的代碼中看到我缺少的東西。我不確定它是否相關......但是渲染調用:部分發生在form_tag內。另外,@teachers是在registration_two控制器操作中定義並填充的Teacher對象的數組。Rails partials not rendering
這裏是我的看法,static_pages/registration_two.html.erb代碼摘錄
<div id="teachers">
<%= render :partial => 'teacher', :collection => @teachers %>
</div>
<%= link_to_function "Add Instructor" do |page|
page.insert_html :bottom, :teachers, :partial => 'teacher', :object => Teacher.new
end %>
這裏是我的一部分,static_pages/_teacher.html.erb
<div class="teacher">
<% fields_for teacher do |teacher_field| %>
<p>
Instructor Name: <%= teacher_field.text_field :name %>
Email: <%= teacher_field.text_field :email %>
<%= link_to_function "remove", "$(this).up('.teacher').remove()" %>
</p>
<% end %>
</div>
眼下只有顯示出來的是'添加教師'按鈕,它不起任何作用。
我基本上試圖模仿Ryan Bates的動態表單提交方法。 http://railscasts.com/episodes/74-complex-forms-part-2