I'm using ransack for searching users based on their company and active/inactive parameter. This works well when used individually, but I want to make use of both simultaneously. For example, if I select company first and then select active/inactive user, then the company name should persist.
Second, is there a facility in ransack to keep both values persisted when I click back or again on users?
UPDATE :
This is my view:
= search_form_for @search, url: search_users_path, method: :post, html: { class: 'sort' } do |f|
= f.label 'company:'
= f.select :company_id_eq,
Company.where('is_inactive = false').collect {|c| [ c.name, c.id ] },
{:include_blank => 'All company users'}, :'data-remote' => true, class: 'searchSelect searchUserSelect'
%div.sort_users
= f.label 'sort Users:'
= f.select :deleted_eq,
[raw("<option value= 0 selected=#{session[:deleted]}>Active Users</option><option value= 1>Inactive Users</option>")],
{}, :'data-remote' => true, class: 'searchSelect searchUserSelect', style: "width: 205px;"
This is my code in controller
@search = User.search(params[:q])
@users = @search.result.includes(:company).order("companies.name, last_name").page(params[:page]).per(20)