0

似乎在模型中犯了一些错误

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

获取 line_item_addons 的未初始化常量

4

3 回答 3

0

我认为应该是

class AddonTypeValue < ActiveRecord::Base
  belongs_to :design
  belongs_to :addon_type
  belongs_to :line_item_addons
  ...
于 2013-08-07T06:29:58.107 回答
0

您无需描述与belongs_to的关联has_onehttp://guides.rubyonrails.org/association_basics.html#the-has-one-association

尝试belongs_to :line_item_addonAddonTypeValue模型中删除

于 2013-08-07T06:31:24.537 回答
0

我在生成模型时犯了一个错误

类名应该是 LineItemAddon 而不是 LineItemAddons

对不起大家

于 2013-08-07T07:02:29.420 回答