0

I have a pretty typical controller with a new action. It looks like this:

  def new
    @child = Child.new
  end

The form fields in my view is also fairly simple. They looks like:

<%= form.text_field :name, placeholder: "John" %>
<%= form.text_field :birthday, placeholder: "MM/DD/YYYY" %>

I'd like my view to submit multiple children in this form. I'll have javascript create them dynamically.

How do I deal with this in the new and action in my controller? And how do I deal with this in my view?

It seems like must be a way to submit an array of children. I feel confident that I can deal with the array in a create controller action, but I'm not sure where to start here.

1 Answer 1

1

You need to use nested_attributes.

Look if this could help.

Cocoon

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.