Rails 简单的表单提交没有将值发送给控制器

Rails Simple form submit not sending value over to controller

我无法弄清楚为什么 simple_form 没有发送文本框值。

这是我的控制器 定义创建 student_station_result = StudentStationResult.new

student = Student.find_by_register_no(params[:result_entry][:register_no])
student_sezzion_id = StudentSezzion.joins(:student_group).where(student_groups: { sezzion_id: params[:sezzion_id] }, student_id: student.id).pluck(:id).first

# TODO: Replaced after the NAPFA result calculation is done
student_station_result.station_point = 1
student_station_result.student_sezzion_id = student_sezzion_id
student_station_result.raw_score = params[:result_entry][:raw_score]
student_station_result.sezzion_station_id = params[:sezzion_station_id]
student_station_result.save!
end

这是我的 html

= simple_form_for :result_entry, url: sezzion_sezzion_station_student_group_student_station_results_path do |f|
- @students.each do |student|
  - student_station_result = get_student_station_result(@station_id, student.id)
  .same-category
    .collapsible-container
        .collapsible-head
          .wrap
            .index
              h1 = student.register_no
            .name
              h3 = student.name
            .grade
              h1 = student_station_result[:performance_grade] if student_station_result.present?
              h5 = "x#{student_station_result[:raw_score]}" if student_station_result.present?
            .arrow
              #arrow-toggle =image_tag('arrow.svg', class: ['arrow-up', 'size'])

          .collapsible-body
            .grade-wrap
              .station-grade A: < 12.01s
              .station-grade B: 12.01 - 13.11
              .station-grade C: 13.11 - 14.11
              .station-grade D: 14.21 - 15.11
              .station-grade E: 15.31 - 16.51

            .score-input
              = f.input :raw_score, label: false, wrapper: false, input_html: { class: ['result-entry-textbox'], value: (student_station_result[:raw_score] if student_station_result.present?)}

              = f.input :register_no, as: :hidden, input_html: { value: student.register_no }
              = f.submit 'SAVE', class: ['result-entry-save', 'result-save-button']

我们将不胜感激。谢谢!

我找到了解决办法,但实际上很愚蠢。因为

= simple_form_for :result_entry, url: sezzion_sezzion_station_student_group_student_station_results_path do |f|

位于页面顶部。因此只让最后一个字段被提交。它应该放在 simple_form 块内。