<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -26,11 +26,17 @@ and sorts by the autocomplete field.
 
     autocomplete_for :user, :name, :limit =&gt; 15, :order =&gt; 'created_at DESC'
       
-With a block you can generate any output you need(passed into render :inline):
+With a block you can generate any output you need (passed into render :inline):
 
     autocomplete_for :post, :title do |items|
       items.map{|item| &quot;#{item.title} -- #{item.id}&quot;}.join(&quot;\n&quot;)
     end
+
+The items passed into the block is an ActiveRecord scope allowing further scopes to be chained:
+
+    autocomplete_for :post, :title do |items|
+      items.for_user(current_user).map(&amp;:title).join(&quot;\n&quot;)
+    end
       
 View
 ----</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -30,14 +30,15 @@ module Grosser
     module ControllerMethods
       def autocomplete_for(object, method, options = {})
         define_method(&quot;autocomplete_for_#{object}_#{method}&quot;) do
+          model = object.to_s.camelize.constantize
           find_options = { 
             :conditions =&gt; [ &quot;LOWER(#{method}) LIKE ?&quot;, '%'+params[:q].to_s.downcase + '%' ],
             :order =&gt; &quot;#{method} ASC&quot;,
             :limit =&gt; 10 
             }.merge!(options)
-          
-          @items = object.to_s.camelize.constantize.find(:all, find_options)
-          
+
+          @items = model.scoped(find_options)
+
           if block_given?
             out = yield(@items)
           else</diff>
      <filename>lib/grosser/autocomplete.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require File.expand_path(&quot;spec_helper&quot;, File.dirname(__FILE__))
 
 describe UsersController do
-  before do
+  before :each do
     @c = UsersController.new
     @c.stubs(:params).returns Hash.new
     @c.stubs(:render)
@@ -12,7 +12,7 @@ describe UsersController do
       class UserAddress &lt; ActiveRecord::Base
         set_table_name :users
       end
-      UserAddress.expects(:find).with do |all,options|
+      UserAddress.expects(:scoped).with do |options|
         options[:conditions] == ['LOWER(full_name) LIKE ?','%hans%']
       end
       
@@ -33,7 +33,7 @@ describe UsersController do
     end
     
     it &quot;oders ASC bey name&quot; do
-      User.expects(:find).with do |all,options|
+      User.expects(:scoped).with do |options|
         options[:order] == 'name ASC'
       end
       @c.autocomplete_for_user_name
@@ -41,7 +41,7 @@ describe UsersController do
     
     it &quot;finds by name&quot; do
       @c.stubs(:params).returns :q=&gt;'Hans'
-      User.expects(:find).with do |all,options|
+      User.expects(:scoped).with do |options|
         options[:conditions] == ['LOWER(name) LIKE ?','%hans%']
       end
       @c.autocomplete_for_user_name
@@ -70,9 +70,9 @@ describe UsersController do
       UsersController.autocomplete_for(:user,:name) do |items|
         items + 'xx'
       end
-      User.expects(:find).returns 'aa'
+      User.expects(:scoped).returns 'aa'
       @c.expects(:render).with {|hash| hash[:inline] == 'aaxx'}
       @c.autocomplete_for_user_name
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>spec/simple_autocomplete_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>50a24a0c927ec953329fddb1cc86977dda3bf374</id>
    </parent>
  </parents>
  <author>
    <name>Bryan Ash</name>
    <email>bryan.a.ash@gmail.com</email>
  </author>
  <url>http://github.com/grosser/simple_auto_complete/commit/df7e46581fd0d29a47c298c4b649eb108eb3b491</url>
  <id>df7e46581fd0d29a47c298c4b649eb108eb3b491</id>
  <committed-date>2009-09-06T09:43:19-07:00</committed-date>
  <authored-date>2009-09-06T08:28:30-07:00</authored-date>
  <message>Using scoped instead of find

Signed-off-by: Michael Grosser &lt;grosser.michael@gmail.com&gt;</message>
  <tree>e0e2b611a31ccb10e1e4596ad5a5b8993a111d5e</tree>
  <committer>
    <name>Michael Grosser</name>
    <email>grosser.michael@gmail.com</email>
  </committer>
</commit>
