Rails强大的参数 – 使用has_many对象中的字段

非常感谢你的帮助。

在我的rails项目中,我有:

  • 位置模型有很多:广告

    class Location  :destroy end 
  • 广告模型

  • 在控制器developer_controller.rb中,我需要使用强参数定位来自位置广告的字段

      params.require(:location).permit(:country, :location, {:ads => [:remote, :days]}) 

我不知道如何正确地从广告对象中检索远程字段和天数

非常感谢

克林顿

你只需要使用_attributes

  params.require(:location).permit(:country, :location, {:ads_attributes => [:remote, :days]})