似乎在模型中犯了一些错误
class LineItemAddons < ActiveRecord::Base
belongs_to :line_item
has_one :addon_type_value
attr_accessible :quantity, :received, :snapshot_price, :status, :line_item_id, :addon_type_value_id
class LineItem < ActiveRecord::Base
belongs_to :design
belongs_to :cart
belongs_to :designer_order
belongs_to :return
belongs_to :return_designer_order
has_many :line_item_addons
class AddonTypeValue < ActiveRecord::Base
belongs_to :design
belongs_to :addon_type
belongs_to :line_item_addon
attr_accessible :description, :name, :position, :price, :addon_type_id, :design_id, :quantity
为订单项插件添加未初始化的常量
答案 0 :(得分:0)
我认为应该是
class AddonTypeValue < ActiveRecord::Base
belongs_to :design
belongs_to :addon_type
belongs_to :line_item_addons
...
答案 1 :(得分:0)
您无需使用belongs_to
描述关联has_one
。
http://guides.rubyonrails.org/association_basics.html#the-has-one-association
尝试从belongs_to :line_item_addon
型号
AddonTypeValue
答案 2 :(得分:0)
我在生成模型时犯了一个错误
类名应该是LineItemAddon而不是LineItemAddons
抱歉伙计