我想學習與Rails 4的數據庫關聯。 在我的應用程序中,我有兩個模型,銷售和產品。 class Sale < ActiveRecord::Base
belongs_to :customer
belongs_to :product
end
class Product < ActiveRecord::Base
self.primary_key = :prod
我有一個簡單的預訂系統: class User < ActiveRecord::Base
has_many :appointments
has_many :bookings
end
class Appointment < ActiveRecord::Base
belongs_to :booking
belongs_to :user
end
cla
嗨在Rails belongs_to關聯的快速問題。 在一個例子中,我們必須模擬Foo &哈。 class Foo < ActiveRecord::Base
end
class Hah < ActiveRecord::Base
belongs_to :foo
end
標準的東西。但是我的問題就出現了。我如何創建代碼,以便Hah模型的每個記錄都有一個