diff --git a/lib/rails-jquery-autocomplete/autocomplete.rb b/lib/rails-jquery-autocomplete/autocomplete.rb index fa8c164..adb31e9 100644 --- a/lib/rails-jquery-autocomplete/autocomplete.rb +++ b/lib/rails-jquery-autocomplete/autocomplete.rb @@ -99,6 +99,9 @@ def get_object(model_sym) def json_for_autocomplete(items, method, extra_data=[], extra_methods=[]) items = items.collect do |item| hash = HashWithIndifferentAccess.new({"id" => item.id.to_s, "label" => item.send(method), "value" => item.send(method)}) + extra_data.each do |datum| + hash[datum] = item.send(datum) + end if extra_data extra_methods.each do |datum| hash[datum] = item.send(datum) end if extra_methods