0

I'm writing a form with nested attributes in Rails 4. I need to add an existing record to a list within a nested form, but I don't know how to preserve the f builder from the parent form, after the ajax call. Is there a way to write this into the session?

Please, for clarity, I am not adding a new empty record, but an existing record, which the user can proceed to modify.

1 Answer 1

1

Adding this to the controller works.

@f = ActionView::Helpers::FormBuilder.new(:object, @customer, view_context, {})

And then in the js.erb file

$("some-div").html("<%= j render('some_partial', f: @f) %>");

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.