Ruby on rails HABTM 3深嵌套
错误:未知属性:大小\u id 项目模型Ruby on rails HABTM 3深嵌套,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,错误:未知属性:大小\u id 项目模型 has_many :sizeables has_many :sizes, through: :sizeables, :dependent => :destroy accepts_nested_attributes_for :sizes, :reject_if => lambda { |a| a.values.all?(&:blank?) }, :allow_destroy => true has_many :sizeab
has_many :sizeables
has_many :sizes, through: :sizeables, :dependent => :destroy
accepts_nested_attributes_for :sizes, :reject_if => lambda { |a| a.values.all?(&:blank?) }, :allow_destroy => true
has_many :sizeables
has_many :items, through: :sizeables
has_one :centimeter
accepts_nested_attributes_for :centimeter, allow_destroy: true
belongs_to :size
尺寸型号
has_many :sizeables
has_many :sizes, through: :sizeables, :dependent => :destroy
accepts_nested_attributes_for :sizes, :reject_if => lambda { |a| a.values.all?(&:blank?) }, :allow_destroy => true
has_many :sizeables
has_many :items, through: :sizeables
has_one :centimeter
accepts_nested_attributes_for :centimeter, allow_destroy: true
belongs_to :size
厘米型号
has_many :sizeables
has_many :sizes, through: :sizeables, :dependent => :destroy
accepts_nested_attributes_for :sizes, :reject_if => lambda { |a| a.values.all?(&:blank?) }, :allow_destroy => true
has_many :sizeables
has_many :items, through: :sizeables
has_one :centimeter
accepts_nested_attributes_for :centimeter, allow_destroy: true
belongs_to :size
项目控制器
def new
@item = Item.new
@size = @item.sizes.build
@size.build_centimeter
end
项目新视图
<%= f.fields_for :sizes do |s| %>
<%= s.fields_for :centimeter do |c| %>
<%= c.text_field :height %>
<% end %>
<% end %>
错误:未知属性:大小\u id您的
项目模型是否接受:大小的嵌套属性?我没看到。是的,对不起,我会更正我的答案!