Skip to content

Nested forms #569

@mbajur

Description

@mbajur

Hello,
I'm trying to use ActiveInteraction with nested forms feature of rails. Here is my view:

<%= form_with model: interaction do |f| %>
  <%= f.fields_for :sections do |ff| %>
    <%= debug ff.object.class %>
  <% end %>
<% end %>

For some reason, the debug line is not returning a nested section record but nil. On the other hand, if i pass a second argument to fields_for (collection) as, say, f.fields_for :sections, record.sections, the debug line returns ActiveRecord::Relation instance instead of the record.

Changing this code to use a direct record instead of interaction objects fixes everything and debug starts returning actual record objects which means that there is something wrong about ActiveInteraction that yelds a collection to fields_for block instead of iterating through objects. Or i just did something wrong :)

Thanks in advance for any clues!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions