diff --git a/lib/rails3-jquery-autocomplete/autocomplete.rb b/lib/rails3-jquery-autocomplete/autocomplete.rb index 365a8ba7..407cc72f 100644 --- a/lib/rails3-jquery-autocomplete/autocomplete.rb +++ b/lib/rails3-jquery-autocomplete/autocomplete.rb @@ -49,7 +49,7 @@ def autocomplete(object, method, options = {}) method = options[:column_name] if options.has_key?(:column_name) term = params[:term] - site_id = 3 + site_id = sessions[:wop_cur_role].site.id if term && !term.blank? #allow specifying fully qualified class name for model object diff --git a/lib/rails3-jquery-autocomplete/orm/active_record.rb b/lib/rails3-jquery-autocomplete/orm/active_record.rb index 62b0fe72..ef7bda86 100644 --- a/lib/rails3-jquery-autocomplete/orm/active_record.rb +++ b/lib/rails3-jquery-autocomplete/orm/active_record.rb @@ -26,12 +26,9 @@ def get_autocomplete_items(parameters) items = items.select(get_autocomplete_select_clause(model, method, options)) unless options[:full_model] items = items.where(get_autocomplete_where_clause(model, term, method, options)). limit(limit).order(order) - puts "model #{model}" - if model = "WopEngine::Person" - puts "model person" + if model == "WopEngine::Person" items = items.joins("join wop_roles on wop_roles.person_id=wop_people.id").where("wop_roles.site_id = ?", site_id) unless site_id.nil? else - puts "else" items = items.where("#{model.table_name}.site_id = ?", site_id) unless site_id.nil? end end