We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent abc6e3a commit bd843ceCopy full SHA for bd843ce
lib/rails3-jquery-autocomplete/orm/mongoid.rb
@@ -21,13 +21,18 @@ def get_autocomplete_items(parameters)
21
term = parameters[:term]
22
limit = get_autocomplete_limit(options)
23
order = get_autocomplete_order(method, options)
24
+ scopes = Array(options[:scopes])
25
26
if is_full_search
27
search = '.*' + term + '.*'
28
else
29
search = '^' + term
30
end
- items = model.where(method.to_sym => /#{search}/i).limit(limit).order_by(order)
31
+
32
+ items = model.scoped
33
+ scopes.each { |scope| items = items.send(scope) } unless scopes.empty?
34
35
+ items = items.where(method.to_sym => /#{search}/i).limit(limit).order_by(order)
36
37
38
0 commit comments