title: Can I access the collection an instance method was called on in ruby on rails
body: <p>I'm working on implementing a search form in a ruby on rails application. The general idea is to use form_tag to submit the search fields (via params) to a search function in the model of the class I'm trying to search. The search function will then iterate through each of the params and execute a scoping function if the name of the function appears in params.</p>
  
  <p>The issue is that when I call the search on a collection like so:</p>
  
  <pre><code>@calendar.reservations.search({:search_email =&gt; "test"})
  </code></pre>
  
  <p>I don't know how to refer to the collection of @calendar.reservations from within the search function.</p>
  
  <p>Additionally I'm confused as to why @calendar.reservations.search(...) works, but Reservations.all.search gives me an error saying you can't call an instance method on an array.</p>
  
  <p>I've got the details of the search method over here: <a href="https://gist.github.com/783964" rel="nofollow">https://gist.github.com/783964</a></p>
  
  <p>Any help would be greatly appreciated!</p>