0
我有模型order.rb:以車ID和投入順序表
class Order < ActiveRecord::Base has_one :cart end
和模型cart.rb:
class Cart < ActiveRecord::Base
include SecurelyPermalinkable
belongs_to :user
belongs_to :order
end
我如何可以採取cart_id和把它放在訂單表的列中?
感謝
邁克爾
對於每個給出的關聯,你不會在你的'order' table.You將有'order_id'有'cart_id'在你的「購物車」表格中。你只是感到困惑。你必須閱讀這些指南http://guides.rubyonrails.org/association_basics.html#the-belongs-to-association – Pavan