Skip to content

Commit

Permalink
don't rely only on arity in calling ProductScope apply_on method
Browse files Browse the repository at this point in the history
Fixes #28
Fixes #33
  • Loading branch information
GarPit authored and radar committed Dec 8, 2013
1 parent d60c241 commit 2f885c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/spree/product_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def products
# Applies product scope on Spree::Product model or another named scope
def apply_on(another_scope)
array = Array.wrap(self.arguments)
unless another_scope.class == ActiveRecord::Relation
unless another_scope.is_a?(ActiveRecord::Relation)
another_scope = another_scope.send(:relation)
end
if Product.respond_to?(self.name.intern)
if (array.blank? || array.size < 2)
if Product.method(self.name.intern).arity == 0
if Product.method(self.name.intern).arity == 0 || self.is_ordering?
another_scope.send(self.name.intern)
else
# Since IDs are comma seperated in the first argument we need to correctly pass the ID array to the with_ids scope.
Expand Down

0 comments on commit 2f885c2

Please sign in to comment.