-2
用戶可以快速搜索數據庫中的特定記錄。我還添加了意願分頁,但是當我這樣做時,搜索欄不起作用。我怎樣才能解決這個問題?組合搜索和will_paginate
我控制器
class VendorsController < ApplicationController
def index
@vendors = Vendor.search(params[:search])
@vendors = Vendor.all.paginate(page: params[:page], per_page: 10)
end
#...
end
指數
#...
<table>
<tr>
<% if user_signed_in? %>
<%= button_to "New Vendor", new_vendor_path, :method => "get" %>
<% end %>
<%= button_to "Inventory", inventories_path, :method => "get" %>
<%= form_tag vendors_path, :method => "get" do %>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :contact_name => nil %>
<% end %>
<div class = "pag" >
<%= will_paginate @vendors %>
</div>
</tr>
</table>
#...
定義請 - _搜索欄不工作_。另請閱讀https://stackoverflow.com/help/how-to-ask –