close

class Product < ActiveRecord::Base
  has_many :orders, :through => :line_items
# ....

會發生

ActiveRecord::HasManyThroughAssociationNotFoundError ...
的錯誤訊息,

在 :through語法前加上 han_many :line_items 即可

完整程式碼:

class Product < ActiveRecode::Base
  has_many :line_items
  has_many :orders, :through => :line_items
# ....

arrow
arrow
    全站熱搜

    bigair 發表在 痞客邦 留言(0) 人氣()