RESTful multiple objects via one form


I’ve looked at all the tutorials on how to create multiple objects of
the same type with one form. However, I cannot get it to work with my
REST app. This is what I have tried:

----- Controller ---------

‘new’ action ----------
def new
@students = []
5.times { @students << }

‘create’ action ----------
params[:students].values do |student| unless student.values.all?(&:blank?)

-------- View -----------
<% @students.each_with_index do |student, index| %>
<% fields_for “students[#{index}]”, student do |s| %>
<%= render :partial => ‘students/student_form’, :locals => {:f =>
s} %>
<% end %>
<% end %>

I cannot figure out why this is not working. The objects will not get
saved. Please help.


Maybe I have to make a :collection => :post method?


Anyone else run into this problem?


I’m not an expert, but no one else seems to be helping.

I’m familiar with 1.1.6 rails, just starting to use 1.2.

In the ‘old days’ in your create task, ‘new’ would just create the
object in memory, similar to your ‘new’ task. ‘Back then’ you had to
either! or do obj.create instead of

Hope it helps you in some direction!