Forum: Ruby on Rails RESTful multiple objects via one form

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
jko170 (Guest)
on 2007-03-02 01:45
(Received via mailing list)
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.
jko170 (Guest)
on 2007-03-02 04:21
(Received via mailing list)
Maybe I have to make a :collection => :post method?
jko170 (Guest)
on 2007-03-02 07:05
(Received via mailing list)
Anyone else run into this problem?
Yottameter (Guest)
on 2007-03-02 07:06
(Received via mailing list)
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!
This topic is locked and can not be replied to.