Ruby on rails 嵌套表单中的链接返回无效关联

Ruby on rails 嵌套表单中的链接返回无效关联,ruby-on-rails,ruby-on-rails-3,forms,associations,nested-forms,Ruby On Rails,Ruby On Rails 3,Forms,Associations,Nested Forms,我正在使用嵌套表单为一组与之关联的模型创建一个复杂的表单列表。但是,当我在表单中添加链接时,它会返回一条错误消息 无效关联。确保接受的\u嵌套的\u属性\u用于:训练\u练习关联 如果我删除链接,一切正常。我必须假设这是一个视图错误,因为删除它不会导致任何问题,我想如果我的关联或接受的嵌套表单不起作用,就会出现问题。我的代码有什么问题以及如何修复它 = nested_form_for(@client_workout) do |f| = f.number_field :client_id,

我正在使用嵌套表单为一组与之关联的模型创建一个复杂的表单列表。但是,当我在表单中添加链接时,它会返回一条错误消息

无效关联。确保接受的\u嵌套的\u属性\u用于:训练\u练习关联

如果我删除链接,一切正常。我必须假设这是一个视图错误,因为删除它不会导致任何问题,我想如果我的关联或接受的嵌套表单不起作用,就会出现问题。我的代码有什么问题以及如何修复它

= nested_form_for(@client_workout) do |f|

  = f.number_field :client_id, placeholder: "Client's Name"

  = f.text_field :description, placeholder: "description"

  = f.text_field :note, placeholder: "notes"

  = f.fields_for :workouts do |workout_form|
    = workout_form.text_field :name, placeholder: "Workout Name"

    = workout_form.fields_for :workout_exercises do |exercise_details_form|
      div Create an Exercise

      = exercise_details_form.fields_for :exercise do |exercise_form|
        = exercise_form.text_field :name, placeholder: "Exercise Name"

      = exercise_details_form.text_field :reps, placeholder: "reps"

      = exercise_details_form.text_field :sets, placeholder: "sets"

      = exercise_details_form.text_field :weight, placeholder: "weight"

      = exercise_details_form.text_field :category, placeholder: "category"

      = exercise_details_form.link_to_remove "Remove this exercise", class: "btn btn-danger"

    / This line of code below is causing the problem
    = workout_form.link_to_add "Add this exercise", :workout_exercises

  = f.submit class: "btn btn-success"
我的
客户锻炼
型号

class ClientWorkout < ActiveRecord::Base
  attr_accessible :workout_id, :description, :note

  belongs_to :workout

  accepts_nested_attributes_for :workout
end
class客户端训练
您应该将其倒置,因为
锻炼
有许多
锻炼客户

= nested_form_for(@workout) do |f|


请把你的客户发出去。
= f.fields_for :client_workouts do |clientworkout_form|