Ruby on rails Rails 4强参数未知参数错误

Ruby on rails Rails 4强参数未知参数错误,ruby-on-rails,strong-parameters,Ruby On Rails,Strong Parameters,正在进行简单的一对多关系,并在服务器日志中获取不允许的参数 杯1---*>触点 params看起来像 Parameters: {"utf8"=>"✓", "authenticity_token"=>"Ay/wRwJTr4u5Vgu5oOrk7z4RC/OfeLJdN9WXuoyU7iQ=", "cup"=>{"name"=>"cupname", "location"=>"Somewhe", "type_ids"=>"1", "contact"=>{"fi

正在进行简单的一对多关系,并在服务器日志中获取不允许的参数

杯1---*>触点

params看起来像

Parameters: {"utf8"=>"✓", "authenticity_token"=>"Ay/wRwJTr4u5Vgu5oOrk7z4RC/OfeLJdN9WXuoyU7iQ=", "cup"=>{"name"=>"cupname", "location"=>"Somewhe", "type_ids"=>"1", "contact"=>{"first_name"=>"Greg", "last_name"=>"Ander", "email"=>"email@me.com", "telephone"=>"444906398"}}, "commit"=>"Create new cup"}
在cups_controller.rb中

编辑
添加了更新的cup_参数和控制器类。还包括型号。

您需要参考
联系人属性,而不是联系人本身

def cup_params
  params.require(:cup).permit(:name,:location,:type_ids,   
    contacts_attributes: [:first_name, :last_name, :email, :telephone ])
end

我也试过了,奇怪的是,我一直在服务器日志中得到同样的结果。
<%= f.fields_for :contacts do |contact_info| %>    
      <%= contact_info.label :first_name %><%= contact_info.text_field :first_name %>
      <%= contact_info.label :last_name %><%= contact_info.text_field :last_name %>
      <%= contact_info.label :email %><%= contact_info.email_field :email %>
      <%= contact_info.label :telephone %><%= contact_info.telephone_field :telephone %>
      <% end %>
class Cup < ActiveRecord::Base
    has_many :contacts
    has_and_belongs_to_many :types
    accepts_nested_attributes_for :contacts
end

class Contact < ActiveRecord::Base
    belongs_to :cup
end
def cup_params
  params.require(:cup).permit(:name,:location,:type_ids,   
    contacts_attributes: [:first_name, :last_name, :email, :telephone ])
end