私はorder
モデルbelongs_to :user
、product
モデル、結合モデルを持っていますorder_product
:
class OrderProduct < ActiveRecord::Base
belongs_to :order
belongs_to :product
end
order_product
モデルには列がありquantity
ます。
p
ユーザーが注文した製品の数を確認するにはどうすればよいu
ですか? Rails 3 のアクティブ レコード クエリ構文を使用し、可能な限りデータベース レベルで行われるソリューションを見つけたいと思います。助けていただければ幸いです。