Permalink
Browse files

Autocomplete on ValueList will filter on Term param and search within…

… text
  • Loading branch information...
1 parent 59df1f7 commit 2f476ba553db3f4bbe33103dd5e8c0225309690e @aviflombaum aviflombaum committed Apr 12, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 app/controllers/value_lists_controller.rb
@@ -13,11 +13,15 @@ def index
end
format.json do
if value_list = ValueList.first(:conditions => ["value = ?", params[:value]])
- values = value_list.values.map(&:value)
+ values = if params[:term].present?
+ value_list.values.find(:all, :conditions => ["values.value LIKE ?", "%#{params[:term]}%"])
+ else
+ value_list.values
+ end
else
values = []
end
- render :json => values
+ render :json => values.map(&:value)
end
end
end

0 comments on commit 2f476ba

Please sign in to comment.