Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an unscoped option #218

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ Only the object's id and the column you are searching on will be returned in JSO
Added option to use scopes. Pass scopes in an array.
e.g `:scopes => [:scope1, :scope2]`

### :unscoped
Added the option to unscope the model
e.g. `:unscoped => true`

#### :column_name
By default autocomplete uses method name as column name. Now it can be specified using column_name options
`:column_name => 'name'`
Expand Down
3 changes: 1 addition & 2 deletions lib/rails3-jquery-autocomplete/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def get_autocomplete_items(parameters)
limit = get_autocomplete_limit(options)
order = get_autocomplete_order(method, options, model)


items = model.scoped
items = (options[:unscoped]) ? model.unscoped : model.scoped

scopes.each { |scope| items = items.send(scope) } unless scopes.empty?

Expand Down