複雑なクエリをレールに書くという論理を理解するためのガイダンスが必要です。複雑なクエリをrailsのアクティブレコードに書く考えを理解するために助けが必要
私は今、私はこのようなフィルタを実装する必要が3つのモデル
Business
has_many :customers
has_many :transactions
Customer
has_many :transactions
belongs_to :business
Transaction
belongs_to :businesss
belongs_to :customer
//transaction model has a attribute amount which tells how much amount has been spent in this particular transaction.
を持っています。私は理解しやすいスクリーンショットの原因を投稿しています。
編集
すべてのトランザクションは、訪問を意味します。総額とは、費やされた総額を意味する。
顧客訪問に関するデータを保持しているどのようなテーブル(ジャストスケッチ。)?取引は訪問を意味しますか? – forker
@forker Yuppすべての取引は訪問を意味します。 –