title: rails3-jquery-autocomplete passing parameter to scope query
body: <p>I'm struggling to find an answer to a problem I have with the rails3-jquery-autocomplete gem.</p>
  
  <p>I have 2 models. Environment &amp; Property. </p>
  
  <pre><code>class Environment &lt; ActiveRecord::Base
    has_many :properties
  
   name: string, envfile: string
  
  class Property &lt; ActiveRecord::Base
    scope :with_environment_id, where(:environment_id =&gt; 14)  
    belongs_to :environment 
  
  name: string, value: string, environment_id: integer
  </code></pre>
  
  <p>I have a view which displays all the properties belonging to a particular environment and in that view the following code which auto searches based on the property name   </p>
  
  <pre><code>&lt;%= form_tag('tbd')%&gt;
    &lt;%= autocomplete_field_tag :property_name, '', autocomplete_property_name_properties_path&gt;
  </code></pre>
  
  <p>The properties controller </p>
  
  <pre><code>class PropertiesController &lt; ApplicationController
    autocomplete :property, :name, :scopes =&gt; [:with_environment_id]
  </code></pre>
  
  <p>and routes.rb has</p>
  
  <pre><code>  get :autocomplete_property_name, :on =&gt; :collection
  </code></pre>
  
  <p>The autocomplete works fine but it returns returns all records in properties table. Where I would like only the properties belonging to the environment displayed in the view.</p>
  
  <p>As you can see I've defined a scope in the property model in which I've hardcoded a valid environment_id to make this work as I would want it.</p>
  
  <p>So my question is how do I pass the environment_id from the view/controller back into the scope?</p>
  
  <p>Perhaps I'm tackling this from the wrong angle.</p>
  
  <p>Apologies if it's a dumb question but it has stumped me all day.</p>