diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 3bfcbf4a..2de67ac4 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -2,6 +2,11 @@ class AccountsController < BaseController before_action :find_account, only: [:follow, :unfollow] before_action :find_admin, only: [:follow, :unfollow] + def index + super + @account_search_query = account_search_query + end + def show; end def follow @@ -44,6 +49,22 @@ def find_admin end def records_filter - @filter = Filter::Account.new(params) + @filter = Filter::Account.new(filter_params) + end + + private + + def filter_params + { + q: account_search_query, + page: params[:page] + } + end + + def account_search_query + q_param = params[:q] + return {} unless q_param.respond_to?(:permit) + + q_param.permit(:username_cont).to_h end end diff --git a/app/views/accounts/index.html.haml b/app/views/accounts/index.html.haml index 327b5efb..9a4560a0 100644 --- a/app/views/accounts/index.html.haml +++ b/app/views/accounts/index.html.haml @@ -6,7 +6,7 @@ .card-header %h3.card-title Registered Users .card-tools.d-flex.justify-content-end.align-items-center - %a{ href: export_accounts_path(format: :csv, q: params[:q]), class: "btn btn-danger", title: "export CSV", style: "display: inline-flex; align-items: center; color: #ffffff !important; margin-right: 8px;" } + %a{ href: export_accounts_path(format: :csv, q: @account_search_query), class: "btn btn-danger", title: "export CSV", style: "display: inline-flex; align-items: center; color: #ffffff !important; margin-right: 8px;" } = image_tag("icons/download.svg", style: "width: 1em; height: 1em; margin-right: 5px;") Export CSV = search_form_for @search do |f|