0

here is my code which is working fine but i want to add multiple attributes i.e last_name, city etc.

def autocomplete
  render json: Doctor.search(params[:query], autocomplete: true, limit: 10).map(&:first_name)
end

I hope following explain my problem and you may got my point, Can i use following code.

def autocomplete
  render json: Doctor.search(params[:query], autocomplete: true, limit: 10).map(&:first_name, :last_name, :city, :country)
end
Murtza
  • 1,386
  • 1
  • 19
  • 27
  • Here is your answer: http://stackoverflow.com/questions/28643262/searchkick-autocomplete-with-multiple-attributes/28643845#28643845 – Sharvy Ahmed Apr 09 '15 at 18:32

1 Answers1

1

You can do:

Doctor.search(params[:query], autocomplete: true, limit: 10).map{|doctor| doctor.slice(:first_name, :last_name, :city, :country) }
Sharvy Ahmed
  • 7,247
  • 1
  • 33
  • 46
Andrew Kane
  • 3,200
  • 19
  • 40