Hi people, I’m trying to use the auto_complete plugin in rails 2.3.2 for
searching from two tables. I’ve researched a lot but I can’t make it
work. This is my code:
------- Application Controller: -------
class ApplicationController < ActionController::Base
…
auto_complete_for :tutor, :name
…
protected
def auto_complete_for_tutor_name @tutors = Tutor.find(:all, :conditions => [“enabled = ‘t’ AND
LOWER(name) LIKE ?”, “%#{params[:tutor][:name]}%”], :limit => 10) @courses = Course.find(:all, :conditions => [“enabled = ‘t’ AND
LOWER(name) LIKE ? OR LOWER(code) LIKE ?”, “%#{params[:tutor][:name]}%”,
“%#{params[:tutor][:name]}%”], :limit => 10)
render :inline => “<%= auto_complete_result(@tutors+@courses, :name)
%>”
end
The point is that if I delete my “custom” auto_complete_for_tutor_name
method from the controller it works, for tutors names only of course.
What am I doing wrong ?
Yep, I want to search for course and tutor name in the same input box,
but I’m not using Shaughnessy’s plugin, I’m using the standard
auto_complete plugin.
I’ve tried commenting the line
#auto_complete_for :tutor, :name
supposing I’m implementing my own method, with no success
I can’t see anything wrong in my code. I’m starting to think that the
problem resides that the methos is defined in the ApplicationController.
Could it be ?
I can’t see anything wrong in my code. I’m starting to think that the
problem resides that the methos is defined in the ApplicationController.
Could it be ?
That’s it!!!
I cant call my custom auto_complete_for… from ApplicationController !
But this is a feature I want along the entire Site, it’s unacceptable to
duplicate the code in EVERY CONTROLLER!!!
:S Thes must be a bug from the plugin, it can’t be called from
ApplicationController