Find exchanges with a particular variant

This commit is contained in:
Rohan Mitchell
2013-08-16 15:12:03 +10:00
parent 1d23446c40
commit 9563aad9fa
2 changed files with 9 additions and 0 deletions

View File

@@ -17,4 +17,5 @@ class Exchange < ActiveRecord::Base
scope :incoming, joins(:order_cycle).where('exchanges.receiver_id = order_cycles.coordinator_id')
scope :outgoing, joins(:order_cycle).where('exchanges.sender_id = order_cycles.coordinator_id')
scope :with_variant, lambda { |variant| joins(:exchange_variants).where('exchange_variants.variant_id = ?', variant) }
end