我已经写了一些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