{"action":"created","comment":{"url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/comments/51985308","id":51985308,"diff_hunk":"@@ -24,27 +24,42 @@ def active_record_get_autocomplete_items(parameters)\n \n         items = (::Rails::VERSION::MAJOR * 10 + ::Rails::VERSION::MINOR) >= 40 ? model.where(nil) : model.scoped\n \n-        scopes.each { |scope| items = items.send(scope) } unless scopes.empty?\n-\n         items = items.select(get_autocomplete_select_clause(model, method, options)) unless options[:full_model]\n         items = items.where(get_autocomplete_where_clause(model, term, method, options)).\n             limit(limit).order(order)\n         items = items.where(where) unless where.blank?\n \n+        if options[:unique]\n+          scopes << -> {\n+            select = \"MIN(#{table_name}.#{model.primary_key}) as #{model.primary_key}, #{table_name}.#{method}\"","path":"lib/rails-jquery-autocomplete/orm/active_record.rb","position":13,"original_position":13,"commit_id":"203a4eabb467bae0afff73007b932d38b9f0ef04","original_commit_id":"203a4eabb467bae0afff73007b932d38b9f0ef04","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [111/80]","created_at":"2016-02-05T07:37:49Z","updated_at":"2016-02-05T07:37:49Z","html_url":"https://github.com/bigtunacan/rails-jquery-autocomplete/pull/48#discussion_r51985308","pull_request_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/comments/51985308"},"html":{"href":"https://github.com/bigtunacan/rails-jquery-autocomplete/pull/48#discussion_r51985308"},"pull_request":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48","id":58387502,"html_url":"https://github.com/bigtunacan/rails-jquery-autocomplete/pull/48","diff_url":"https://github.com/bigtunacan/rails-jquery-autocomplete/pull/48.diff","patch_url":"https://github.com/bigtunacan/rails-jquery-autocomplete/pull/48.patch","issue_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/issues/48","number":48,"state":"open","locked":false,"title":"Fix #45 Make scopes option can accepts Proc","user":{"login":"lingceng","id":2259878,"avatar_url":"https://avatars.githubusercontent.com/u/2259878?v=3","gravatar_id":"","url":"https://api.github.com/users/lingceng","html_url":"https://github.com/lingceng","followers_url":"https://api.github.com/users/lingceng/followers","following_url":"https://api.github.com/users/lingceng/following{/other_user}","gists_url":"https://api.github.com/users/lingceng/gists{/gist_id}","starred_url":"https://api.github.com/users/lingceng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lingceng/subscriptions","organizations_url":"https://api.github.com/users/lingceng/orgs","repos_url":"https://api.github.com/users/lingceng/repos","events_url":"https://api.github.com/users/lingceng/events{/privacy}","received_events_url":"https://api.github.com/users/lingceng/received_events","type":"User","site_admin":false},"body":"Scopes can also override the select and where.\r\nSo you can use code like following to query unique result.\r\n\r\n    autocomplete :item, :brand, full: true, scopes: [-> { unscope(:select).select('MIN(id) as id, brand').group(:brand) }]","created_at":"2016-02-05T04:33:20Z","updated_at":"2016-02-05T07:37:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2d6297ec8a05be64c2273eefd31c1e51a7b9631d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48/commits","review_comments_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48/comments","review_comment_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/issues/48/comments","statuses_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/statuses/203a4eabb467bae0afff73007b932d38b9f0ef04","head":{"label":"lingceng:master","ref":"master","sha":"203a4eabb467bae0afff73007b932d38b9f0ef04","user":{"login":"lingceng","id":2259878,"avatar_url":"https://avatars.githubusercontent.com/u/2259878?v=3","gravatar_id":"","url":"https://api.github.com/users/lingceng","html_url":"https://github.com/lingceng","followers_url":"https://api.github.com/users/lingceng/followers","following_url":"https://api.github.com/users/lingceng/following{/other_user}","gists_url":"https://api.github.com/users/lingceng/gists{/gist_id}","starred_url":"https://api.github.com/users/lingceng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lingceng/subscriptions","organizations_url":"https://api.github.com/users/lingceng/orgs","repos_url":"https://api.github.com/users/lingceng/repos","events_url":"https://api.github.com/users/lingceng/events{/privacy}","received_events_url":"https://api.github.com/users/lingceng/received_events","type":"User","site_admin":false},"repo":{"id":51049977,"name":"rails-jquery-autocomplete","full_name":"lingceng/rails-jquery-autocomplete","owner":{"login":"lingceng","id":2259878,"avatar_url":"https://avatars.githubusercontent.com/u/2259878?v=3","gravatar_id":"","url":"https://api.github.com/users/lingceng","html_url":"https://github.com/lingceng","followers_url":"https://api.github.com/users/lingceng/followers","following_url":"https://api.github.com/users/lingceng/following{/other_user}","gists_url":"https://api.github.com/users/lingceng/gists{/gist_id}","starred_url":"https://api.github.com/users/lingceng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lingceng/subscriptions","organizations_url":"https://api.github.com/users/lingceng/orgs","repos_url":"https://api.github.com/users/lingceng/repos","events_url":"https://api.github.com/users/lingceng/events{/privacy}","received_events_url":"https://api.github.com/users/lingceng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lingceng/rails-jquery-autocomplete","description":"An easy and unobtrusive way to use jQuery's autocomplete with Rails 3 and later.","fork":true,"url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete","forks_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/forks","keys_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/teams","hooks_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/hooks","issue_events_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/issues/events{/number}","events_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/events","assignees_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/assignees{/user}","branches_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/branches{/branch}","tags_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/tags","blobs_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/git/refs{/sha}","trees_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/statuses/{sha}","languages_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/languages","stargazers_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/stargazers","contributors_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/contributors","subscribers_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/subscribers","subscription_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/subscription","commits_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/commits{/sha}","git_commits_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/git/commits{/sha}","comments_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/comments{/number}","issue_comment_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/issues/comments{/number}","contents_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/contents/{+path}","compare_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/merges","archive_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/downloads","issues_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/issues{/number}","pulls_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/pulls{/number}","milestones_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/milestones{/number}","notifications_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/labels{/name}","releases_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/releases{/id}","deployments_url":"https://api.github.com/repos/lingceng/rails-jquery-autocomplete/deployments","created_at":"2016-02-04T03:38:32Z","updated_at":"2016-02-04T03:38:33Z","pushed_at":"2016-02-05T07:37:42Z","git_url":"git://github.com/lingceng/rails-jquery-autocomplete.git","ssh_url":"git@github.com:lingceng/rails-jquery-autocomplete.git","clone_url":"https://github.com/lingceng/rails-jquery-autocomplete.git","svn_url":"https://github.com/lingceng/rails-jquery-autocomplete","homepage":"","size":176,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bigtunacan:master","ref":"master","sha":"3438cdc88c831449813e07df62a3321a92c01eb9","user":{"login":"bigtunacan","id":1995168,"avatar_url":"https://avatars.githubusercontent.com/u/1995168?v=3","gravatar_id":"","url":"https://api.github.com/users/bigtunacan","html_url":"https://github.com/bigtunacan","followers_url":"https://api.github.com/users/bigtunacan/followers","following_url":"https://api.github.com/users/bigtunacan/following{/other_user}","gists_url":"https://api.github.com/users/bigtunacan/gists{/gist_id}","starred_url":"https://api.github.com/users/bigtunacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigtunacan/subscriptions","organizations_url":"https://api.github.com/users/bigtunacan/orgs","repos_url":"https://api.github.com/users/bigtunacan/repos","events_url":"https://api.github.com/users/bigtunacan/events{/privacy}","received_events_url":"https://api.github.com/users/bigtunacan/received_events","type":"User","site_admin":false},"repo":{"id":29552032,"name":"rails-jquery-autocomplete","full_name":"bigtunacan/rails-jquery-autocomplete","owner":{"login":"bigtunacan","id":1995168,"avatar_url":"https://avatars.githubusercontent.com/u/1995168?v=3","gravatar_id":"","url":"https://api.github.com/users/bigtunacan","html_url":"https://github.com/bigtunacan","followers_url":"https://api.github.com/users/bigtunacan/followers","following_url":"https://api.github.com/users/bigtunacan/following{/other_user}","gists_url":"https://api.github.com/users/bigtunacan/gists{/gist_id}","starred_url":"https://api.github.com/users/bigtunacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigtunacan/subscriptions","organizations_url":"https://api.github.com/users/bigtunacan/orgs","repos_url":"https://api.github.com/users/bigtunacan/repos","events_url":"https://api.github.com/users/bigtunacan/events{/privacy}","received_events_url":"https://api.github.com/users/bigtunacan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bigtunacan/rails-jquery-autocomplete","description":"An easy and unobtrusive way to use jQuery's autocomplete with Rails 3 and later.","fork":false,"url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete","forks_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/forks","keys_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/teams","hooks_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/hooks","issue_events_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/issues/events{/number}","events_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/events","assignees_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/assignees{/user}","branches_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/branches{/branch}","tags_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/tags","blobs_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/git/refs{/sha}","trees_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/statuses/{sha}","languages_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/languages","stargazers_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/stargazers","contributors_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/contributors","subscribers_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/subscribers","subscription_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/subscription","commits_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/commits{/sha}","git_commits_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/git/commits{/sha}","comments_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/comments{/number}","issue_comment_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/issues/comments{/number}","contents_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/contents/{+path}","compare_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/merges","archive_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/downloads","issues_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/issues{/number}","pulls_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls{/number}","milestones_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/milestones{/number}","notifications_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/labels{/name}","releases_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/releases{/id}","deployments_url":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/deployments","created_at":"2015-01-20T21:05:49Z","updated_at":"2016-01-27T20:27:56Z","pushed_at":"2016-02-05T07:37:42Z","git_url":"git://github.com/bigtunacan/rails-jquery-autocomplete.git","ssh_url":"git@github.com:bigtunacan/rails-jquery-autocomplete.git","clone_url":"https://github.com/bigtunacan/rails-jquery-autocomplete.git","svn_url":"https://github.com/bigtunacan/rails-jquery-autocomplete","homepage":"","size":218,"stargazers_count":81,"watchers_count":81,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":11,"forks":31,"open_issues":11,"watchers":81,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48"},"html":{"href":"https://github.com/bigtunacan/rails-jquery-autocomplete/pull/48"},"issue":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/issues/48"},"comments":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/bigtunacan/rails-jquery-autocomplete/statuses/203a4eabb467bae0afff73007b932d38b9f0ef04"}}}}