Question: I'm using the Rails gem rails3-jquery-autocomplete to add categories to posts. 

I would like to restrict the search to include only categories that belong to the current user or post's author in the results.

The documentation says that I can specify a scope:

> 
> :scopes
> 
> 
> Added option to use scopes. Pass scopes in an array. e.g :scopes =>
>  [:scope1, :scope2]
> 
> 
> 

But I'm not sure how I would pass the user id here? 

It seems like a comon scenario, am I missing something obvious?

I found an answer that suggests modifying the `get_item` method, but that seems to break the auto-complete

[Scoping the results for rails3 jquery autocomplete plugin](https://stackoverflow.com/questions/4858816/scoping-the-results-for-rails3-jquery-autocomplete-plugin)

Answer: 
I had a similar problem I solved thanks to the answers above.

My autocomplete also worked against a User model, but I needed to restrict the results to the user's institution (Institution has many :users). My controller creates an @institution instance variable that is accessed in the view. 

Although the get\_autocomplete\_items method cannot directly access the instance variable, I found that the data CAN be passed to autocomplete as a parameter (note: I use the simple\_forms gem, so the input call looks a little different than the standard rails syntax).

In my view:

```
<%= f.input :email,  :url => autocomplete_user_email_institutions_path(:institution_id=>@institution.id.to_s), :as => :autocomplete %>

```

In my controller:

```
  autocomplete :user, :email, :extra_data => [:first_name, :last_name]

  def get_autocomplete_items(parameters)
    super(parameters).where(:institution_id => params[:institution_id])
  end

```

My autocomplete list is now scoped to just the users who work for a particular institution.
To answer the question posed by @ctilley79, multiple autocompletes is not a problem because, in addition to the possibility of passing more values in the params hash, you also have access to the autocomplete parameters. On my form (as an example), I have both a City and a Zip autocomplete. I need to restrict the City to those in a certain state. So my controller action looks like this:

```
def get_autocomplete_items(parameters)
  if (parameters[:model] == City)
    super(parameters).where("state_id" => params[:state_id])
  else
    super(parameters)
  end
end

```

You also have access to the method in case you need it. Do logger.debug on the parameters to see all that is available.