mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-05 07:01:03 -05:00
auto-suggest to use existing search
This commit is contained in:
@@ -62,7 +62,7 @@ class CropsController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json {
|
||||
render :json => @all_matches
|
||||
render :json => Crop.autosuggest(params[:term])
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ class Crop < ActiveRecord::Base
|
||||
tokenizer: {
|
||||
gs_edgeNGram_tokenizer: {
|
||||
type: "edgeNGram",
|
||||
min_gram: 1,
|
||||
min_gram: 2,
|
||||
max_gram: 20,
|
||||
token_chars: [ "letter", "digit" ]
|
||||
}
|
||||
@@ -261,4 +261,8 @@ class Crop < ActiveRecord::Base
|
||||
)
|
||||
response.records.to_a
|
||||
end
|
||||
|
||||
def self.autosuggest(term)
|
||||
where("name ILIKE ?", "%#{term}%")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user