How do I display dynamic fields from collection and bind data back?
I just started working on Ruby on Rails project for maintenance. I have array of objects and want to display separate section of fields for each object. They have design to call field factory that generate field dynamically. I could display the data but it not binding the value back on page submission
ClassRoom Controller
ClassRoom Controller
def arrayOfStudents
@arrayOfStudents||= begin
if Array(attributes[:arrayOfStudents]).any?
attributes[:arrayOfStudents] ==> this always have 5 objects of Students with variables name and ageMy view
<% @classroom.arrayOfStudents.each do |crt| %>
<%= f.fields_for crt do |ff| %>
<%= render 'shared/model_attributes/field', f: ff, field: {type: :money, cols: 6, name: :name, label: 'Name'}, static: static %>
<%= render 'shared/model_attributes/field', f: ff, field: {type: :percent, cols: 6, name: :age, label: 'Age'}, static: static %>
<%= puts "testing"%>
<% end %>
<% end %>attributes/field
<% when :money %>
<%= f.labeled_text_field_with_begin_addon(field[:name], '$', label: field[:label], class: class_list, placeholder: field[:label], maxlength: field[:maxlength], display_name: false, disabled: false, reserve_error_space: true, help_text: field[:help_text]) %>After editing the value and submit control comes to controller. But the values inside :arrayOfStudents are unchanged . Am I missing generating dynamic fields correctly?