I'm using autocomplete widget of jquery-ui. I found that it sends its parameters as term and it needs a json like this
[{"label": "Client1"},{"label": "Client2"} ]
Instead I am getting
[{"client":{"label":"Cliente"}}]
clients_controller.rb
def index
@client = Client.all
@client = Client.paginate(:page => params[:page])
if params[:term].present?
@client = @client.where("client_name LIKE ? ", "%#{params[:term]}%")
else
@client = @client.paginate(page: params[:page])
end
respond_to do |format|
format.html
format.json
end
end
_client.json.jbuilder
json.client do
json.label client.client_name
end
How can I format a json as I needing it?