diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index d6006b4e1a..4fc49dbd75 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -94,10 +94,8 @@ class Enterprise < ActiveRecord::Base select('DISTINCT enterprises.*') } scope :not_ready_for_checkout, lambda { - # When ready_for_checkout is empty, ActiveRecord generates the SQL: - # id NOT IN (NULL) - # I would have expected this to return all rows, but instead it returns none. But we want to - # return all rows when there are no enterprises ready for checkout. + # When ready_for_checkout is empty, return all rows when there are no enterprises ready for + # checkout. ready_enterprises = Enterprise.ready_for_checkout ready_enterprises.present? ? where("id NOT IN (?)", ready_enterprises) : where("TRUE") } diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 071ee49f22..07b71d606c 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -9,7 +9,7 @@ class OrderCycle < ActiveRecord::Base has_many :exchanges, :dependent => :destroy # These scope names are prepended with "cached_" because there are existing accessor methods - # :incoming_exchanges and :outgoing_exchanges. Future work can be done to name these properly. + # :incoming_exchanges and :outgoing_exchanges. has_many :cached_incoming_exchanges, conditions: { incoming: true }, class_name: "Exchange" has_many :cached_outgoing_exchanges, conditions: { incoming: false }, class_name: "Exchange" @@ -18,9 +18,6 @@ class OrderCycle < ActiveRecord::Base has_and_belongs_to_many :schedules, join_table: 'order_cycle_schedules' - # TODO: DRY the incoming/outgoing clause used in several cases below - # See Spree::Product definition, scopes variants and variants_including_master - # This will require these accessors to be renamed attr_accessor :incoming_exchanges, :outgoing_exchanges validates_presence_of :name, :coordinator_id