初めに
過去の検索機能実装の記事はこちら。
ページネーション導入済みで、一覧画面では使用してましたが、
検索結果では使わず、全表示にしていました・・・。
なので、今回検索結果の表示画面でもページネーションを使用していきたいと思います。
コントローラー
class Users::SearchesController < ApplicationController
def index
users= User.search(params[:keyword])
@users=users.page(params[:page]).per(25)
end
end
これでほぼOKです!
VIEW 検索結果表示画面
<div class="pagination pagination-sm justify-content-center">
<%= paginate @users %></div
以上で、完了です。