I'm using this gist to build autocomplete functionality in my Rails app.
I'm saving record in Shoe model attribute like below
"nike air, nike steam,nike softy ,nike strength" #comma separated words
My controller code is below
def shoes
shoes_list = []
shoes = Shoe.all
shoes.each do |shoe|
shoes_list << shoe.model.split(',')
end unless shoes.blank?
if params[:term]
like = "%".concat(params[:term].concat("%"))
# shoes = Shoe.where("model like ?", like)
# **How i make like query to "shoes_list" same like above commented line?**
else
shoes = Shoe.all
end
list = shoes.map { |u| Hash[id: u.id, label: u.model, model: u.model] }
render json: list
end
How do I render it in json format?
Shoerecord. For example, if I start typing nike, it will show autocomplete suggestions nike air, nike steam, nike softy, nike strength... all separate words but all pointing to the sameShoerecord?