在closes_nested_attributes_for上打破模型,没有关联错误

ped*_*ete 2 ruby-on-rails nested-attributes

我有一个Wine模特,一个葡萄酒可以有很多Varietals.

我有一个WineVarietals模型,并通过该表加入葡萄酒到品种.

当我放入accepts_nested_attributes_for :wine_varietals我的模型时,我得到 No association found for namewine_varietals'.它已经定义了吗?`

但我确实在我的模型中有关联.

我的葡萄酒模型是

class Wine < ActiveRecord::Base

    attr_accessible :name, :winery_id, :wine_varietals_attributes
    accepts_nested_attributes_for :wine_varietals

    belongs_to :winery
    has_many :wine_varietals
    #has_and_belongs_to_many :varietals, :join_table => :wine_varietals
    has_many :wine_photos
    has_many :vintages

我也有WineVarietal和Varietal模型.

如果我注释掉该accepts_nested_attributes_for行,则错误就会消失.

我尝试过不同形式的复数wines_varietals,wine_varietal但似乎无法摆脱这种错误.

sid*_*ick 10

accepts_nested_attributes_for :wine_varietals下方添加一行has_many :wine_varietals