crowdint/rails3-jquery-autocomplete — pull request #121 by budu (2011-12-05 18:05:12+00:00)
Title: Added the possibility to use scopes with arguments, by passing a array or a lambda via the scopes option.

This can be really useful in certain situations, there's two ways of using scopes with arguments, by sending an array and with a lambda. Here's an example with the former:

autocomplete :user, :name, :scopes => [[:older_than, 21]]

And for lambdas:

before_filter :find_settings
attr_reader :settings
autocomplete :user, :name, :scopes => [lambda {|users, options|
users.older_than options[:controller].settings.minimum_age}]

The lambda way isn't really as nice as I'd like, maybe giving the lambda direct access to the controller environment would be better but I'm not sure how to do that.