1

Using Rails 3.1.1. & 'rails3-jquery-autocomplete'

I think this question should be quite simple for anyone using the rails3-jquery-autocomplete gem but I can't find any info on it on www. I have a very straightforward setup of the rails3-jquery-autocomplete and it is working fine.

Using:

<%= f.autocomplete_field :query, autocomplete_search_result_query_search_results_path %>

where query is a column in my search_result table.

The search_results table also have a status_id-column where 1 = OK and 2 = NOT OK.

Thus, I want :query to be filtered so that only queries where status_id = 1 is fetched. How can I do that? As it is now all queries are fetched.

Putting it simple I want ":query" to equal select query where status_id = 1.

Controller:

  autocomplete :search_result, :query, :full => true

Routes:

  resources :search_results, :only => [:index, :show, :new, :create], :path => 'sokresultat' do
    get :autocomplete_search_result_query, :on => :collection
  end
Christoffer
  • 2,271
  • 3
  • 26
  • 57

1 Answers1

0

I realized I should probably used :scope but I could never make that work. Instead this ticket solved the problem for me Rails gem rails3-jquery-autocomplete how to scope by user

Community
  • 1
  • 1
Christoffer
  • 2,271
  • 3
  • 26
  • 57