I don't really see how to use this method. I also had trying to joint
the professionals table with this:
auto_complete_for :user, :nicename, :limit => 15, :order => 'nicename,
:include => :professionals
but that do not work because I just can add a :conditions option.
The auto_complete_for macro just generates a method with that name.
You need to *remove* the macro and *implement* the method. Your custom
action auto_complete_for_user_nicename typically takes what the user
has typed from the params hash and issues a custom query. If you trace
Ajax calls with firebug you'll see auto completion just invokes that
action (by default). In the action you are free to do anything to
figure out the completions and send the results back to the browser.
Once you have the collection in @users the auto_complete_result helper
eases building the results the way the client expects them.
The auto_complete_for macro just generates a method with that name.
You need to *remove* the macro and *implement* the method. Your custom
action auto_complete_for_user_nicename typically takes what the user
has typed from the params hash and issues a custom query. If you trace
Ajax calls with firebug you'll see auto completion just invokes that
action (by default). In the action you are free to do anything to
figure out the completions and send the results back to the browser.
Once you have the collection in @users the auto_complete_result helper
eases building the results the way the client expects them.
Thanks a lot. Now it's okay
If that could be useful, I copy past my method:
def auto_complete_for_user_nicename
@users = User.find(:all, :include => :professional, :conditions =>
['user_id > ? and nicename LIKE ?', 0, "%#{params[:user][:nicename]}%"])
render :inline => '<%= auto_complete_result @users, :nicename %>'
end