【问题标题】:Twice nested attributes form_for两次嵌套属性 form_for
【发布时间】:2013-02-24 18:05:49
【问题描述】:

我正在寻找双重嵌套属性表单的解决方案。球队有几个球员,每个球员都有几轮。我在模型中添加了 accept_nested_attributes。 这种方式对我不起作用。

 <% form_for(@team) do |team_fields| %>
     ...SOME FIELDS...
   <% team_fields.fields_for :players do |player_fields| %>...SOME FIELDS...

      <% player_fields.fields_for :rounds do |round_fields| %>
         <%= round_fields.text_field :message%>
      <%end%>
   <%end%>
 <%end%> 

【问题讨论】:

    标签: ruby-on-rails ruby nested-attributes form-for fields-for


    【解决方案1】:

    尝试将您的电话打印到.fields_for。

    &lt;%= player_fields.fields_for :rounds do |round_fields| %&gt;

    【讨论】:

    • 谢谢,我在我的问题中忘记了它们。但我发现了“大错误”。谢谢:)
    • 哦,我以为它是固定的:/ 但是当我编辑 text_field 中的值时,提交会创建大量的回合 ....
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多