ネストされたフォームを送信するときに問題が発生しています。
私の2つのモデル:
#PLANNING MODEL
class Planning < ActiveRecord::Base
has_many :periods
belongs_to :plannable, polymorphic: true
attr_accessible :quantity, :periods_attributes
accepts_nested_attributes_for :periods
end
#PERIOD MODEL
class Period < ActiveRecord::Base
belongs_to :planning
attr_accessible :planned_quantity, :planning_id
end
そして私の形で:
...
<% @planning.periods.each do |period| %>
<%= f.fields_for(period) do |builder| %>
<%= builder.label :planned_quantity, "Planned quantity" %>
<%= builder.number_field :planned_quantity%>
<%end%>
<%end%>
...
次のように表示されると、送信するまで、すべてが思いどおりに表示されます。
Can't mass-assign protected attributes: period
誰かが私を助ける方法を知っていますか? ウェブ全体を検索しています...
ありがとう!