I am on a ruby ββon rails and I have two models, the goal is to search the site on two models, I use twitter typeahead, but the problem I have is json, which should be a single object.
I'm not sure the best way to convert my two objects into one. Here is the code
@users= Search.user(params[:query]) @articles= Search.article(params[:query]) respond_to do |format| format.html
I'm not sure what the best way is, or I can't find the best documentation to combine these two models into one. I don't know if to_json, as_json or concat would be better.
The idea is to get the result of the next json from
{"art":["John","Serge","Dean","feng","Heather"],"user":["Ontario high school teachers drop next week walkout plan","Air Canada to appeal Quebec court ruling on Aveos"]}
To the next
{"result":["John","Serge","Dean","feng","Heather", "Ontario high school teachers drop next week walkout plan","Air Canada to appeal Quebec court ruling on Aveos"]}
source share