多态嵌套表单对象创建的未知属性

我试图通过fields_for创建一个关联的多态对象。

我得到一个未知的属性错误,虽然父母被创建时,@ order参数是不是以某种方式通过?

家长/订单控制器 –

# GET /orders/new def new @order = Order.new @order.build_patient @order.product = OrthosisSpecification.new end # GET /hotels/1/edit def edit @order.build_patient end # POST /orders # POST /orders.json def create @order = Order.new(order_params) respond_to do |format| if @order.save format.html { redirect_to @order, notice: 'Order was successfully created.' } format.json { render :show, status: :created, location: @order } else format.html { render :new } format.json { render json: @order.errors, status: :unprocessable_entity } end end end private # Never trust parameters from the scary internet, only allow the white list through. def order_params params.require(:order).permit! end 

表格 –

      

订单模型 –

 class Order < ActiveRecord::Base has_one :patient belongs_to :product, polymorphic: true accepts_nested_attributes_for :patient, reject_if: proc { |attributes| attributes['first_name'].blank? }, allow_destroy: true accepts_nested_attributes_for :product end 

完全错误 –

 unknown attribute 'orthosis_specification' for Order. 

order_params –

 >> order_params => {"patient_attributes"=>{"first_name"=>"", "last_name"=>"", "dob"=>"", "sex"=>"1", "diagnosis"=>"1", "posterior_flattening"=>"1", "circumference"=>"", "ap"=>"", "ml"=>"", "ci"=>"", "frontal_area"=>"1", "parietal_lateral"=>"1", "ear_position"=>"1"}, "orthosis_specification"=>{"transfer_name"=>"1", "modifications"=>"1", "primary_mods"=>"1", "top_opening"=>"1", "side_opening"=>"1", "chape_position"=>"1"}, "order_date"=>"", "date_required"=>""} 

参数 –

 authenticity_token"=>"v6gVARW+vnApuZpit6IW81ouytlWWQa1Orb4kymseESZmgiFI4KYhOrYyRQuu7yn3mijRp9m7LlFxQlMq7OaAA==", "order"=>{"patient_attributes"=>{"first_name"=>"", "last_name"=>"", "dob"=>"", "sex"=>"1", "diagnosis"=>"1", "posterior_flattening"=>"1", "circumference"=>"", "ap"=>"", "ml"=>"", "ci"=>"", "frontal_area"=>"1", "parietal_lateral"=>"1", "ear_position"=>"1"}, "orthosis_specification"=>{"transfer_name"=>"1", "modifications"=>"1", "primary_mods"=>"1", "top_opening"=>"1", "side_opening"=>"1", "chape_position"=>"1"}, "order_date"=>"", "date_required"=>""}, "commit"=>"Create Order", "controller"=>"orders", "action"=>"create"} 

矫形器规格模型 –

 class OrthosisSpecification  :product, class_name: 'Order' accepts_nested_attributes_for :order end 

谢谢你的帮助!