Rails partials not rendering
I've written some partials but they don't seem to be rendering. Some of the other posters who have reported the same issue made the mistake of using <% ... %> for embedded ruby code instead of <%= ... %>. I'm not making that error, so I'm not sure why my partials aren't rendering. Perhaps someone will see something in my code which I am missing. I'm not sure if it's relevant...but the call to render :partial occurs inside a form_tag. Also, @teachers is an array of Teacher objects that is defined and populated in the registration_two controller action.
Here is a code excerpt from my view, 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 %>
And here is my partial, 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>
Right now the only thing that shows up is the 'Add Instructors' button, which doesn't do anything.
I'm essentially trying to imitate Ryan Bates' approach for dynamic form submissions. http://railscasts.com/episodes/74-complex-forms-part-2
Replace <% fields_for with <%= fields_for
Sidenote, you could simply use:
<%= render @teachers %>