<%= form_with model: @text_field, url: character_sheet_section_text_fields_path(@section) do |f| %> <% if @text_field.new_record? %> <%= f.fields_for :character_sheet_feature do |ff| %> <%= ff.hidden_field :featurable_id, value: @text_field.id %> <%= ff.hidden_field :character_sheet_section_id, value: @section.id %> <% end %> <% end %> <%= f.label :name %> <%= f.text_field :name %> <%= display_form_errors(@section, :name) %> <%= f.submit button_text %> <% end %>