레일에서 루비를 처음 사용했습니다. 사실, 나는 어제부터 그 일을 시작했다. 모든 개념은 저에게 새로운 것입니다. 내가 도움이 필요한 문제가 붙어 있습니다.레일에 루비에서 자동 완성 사용하기
이것은 내 컨트롤러 파일입니다.
class ProductsController < ApplicationController
def new
#render :layout => 'mylayout'
end
def result
#@site_matches = Srch.find(:all,:conditions =>["q=?",params[:q]])
#render :layout => 'mylayout'
end
def show
#render text: params[:products].inspect
@site_matches = Srch.where("name like ?", "%#{params[:name]}%")
end
end
이것은 내 검색 단어를 받고 결과를 표시하는 내 HTML 파일입니다.
<h1>Results for your search.</h1>
<%= render "products/new"%>
<table><tr><th>Name</th><th>Max. Price</th><th>Min. Price</th><th>Discount</th><th>Image</th></tr>
<% for prod in @site_matches %>
<tr><td><%= prod.name %></td><td><%= prod.maxprice%></td><td><%= prod.minprice%></td><td><%= prod.discount%></td><td> <%= image_tag(prod.image, :alt => "logo", :size => "75x75") %> </td></tr>
<% end %>
</table>
</br>
<%= link_to "Search again" , "new" %>
데이터를 가져 와서 결과를 올바르게 표시 할 수 있습니다. 하지만 기존의 자동 완성 기능을 추가해야합니다. 어떻게해야합니까? i) 흑점을 사용하지 않고 ii) 태양 흑점을 사용하는 방법도?