Skip to content

Commit

Permalink
make aaf work with named, default and dynamic scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkraemer committed Mar 23, 2010
1 parent 93ea286 commit 3c14b1c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/class_methods.rb
Expand Up @@ -143,14 +143,10 @@ def aaf_index
# +limit+ if you specify any active record conditions that further limit
# the result. Use +limit+ and +offset+ as AR find_options instead.
# +page+ and +per_page+ are supposed to work regardless of any
# +conitions+ present in +find_options+.
# +conditions+ present in +find_options+.
def find_with_ferret(q, options = {}, find_options = {})
if respond_to?(:scope) && scope(:find, :conditions)
if find_options[:conditions]
find_options[:conditions] = "(#{find_options[:conditions]}) AND (#{scope(:find, :conditions)})"
else
find_options[:conditions] = scope(:find, :conditions)
end
find_options[:conditions] ||= '1=1' # treat external scope the same as if :conditions present (i.e. when it comes to counting results)
end
return ActsAsFerret::find q, self, options, find_options
end
Expand Down

0 comments on commit 3c14b1c

Please sign in to comment.