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

Answers


Replace <% fields_for with <%= fields_for

Sidenote, you could simply use:

<%= render @teachers %>

Need Your Help

Can an ASP MVC contoller action receive a byte?

asp.net-mvc bytearray parameter-passing

I have an ASP MVC application which I also use (as a requirment) as a web service for a mobile application.

How to compare row values of two gridviews with dropdownlist column in asp.net?

asp.net vb.net gridview

I have two gridviews. The first one has a dropdownlist. When a user clicks a button named 'Show' data will be displayed on both gridviews where data comes from database. The row data on column with

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.