title: Rails filterrific not updating view after selection a filter
body: <p>I am trying to add filterrific to my rails app. I followed <a href="http://filterrific.clearcove.ca/" rel="nofollow noreferrer">this</a> tutorial but my live update is not working. I need to hit refresh to update the results in my view.
  I tried looking for solution and found some links (<a href="https://stackoverflow.com/questions/39736417/view-is-not-updating-after-applying-filter-ruby-rails-filterrific">Link 1</a>, <a href="https://stackoverflow.com/questions/47402011/rails-filterrific-live-update-not-working">Link 2</a>), but no success. Below is my code.</p>
  
  <p>agent.rb</p>
  
  <pre><code>class Agent &lt; ApplicationRecord
    STATUS_ACTIVE = 'ACTIVE'.freeze
    STATUS_INACTIVE = 'INACTIVE'.freeze
  
    filterrific(
        default_filter_params: { sorted_by: 'name_asc' },
        available_filters: [
            :sorted_by,
            :search_query,
            :with_agent_id,
        ]
    )
  
    scope :sorted_by, lambda { |sort_option|
      direction = /desc$/.match?(sort_option) ? "desc" : "asc"
      case sort_option.to_s
      when /^name/
        order("name #{direction}")
      when /^location/
        order("location #{direction}")
      else
        raise(ArgumentError, "Invalid sort option: #{sort_option.inspect}")
      end
    }
    scope :search_query, lambda { |query|
      # Filters students whose name or email matches the query
    }
    scope :with_agent_id, lambda { |agent_ids|
      where(id: agent_ids)
    }
  
    # This method provides select options for the `sorted_by` filter select input.
    # It is called in the controller as part of `initialize_filterrific`.
    def self.options_for_sorted_by
      [
          ["Name (a-z)", "name_asc"],
          ["Name (z-a)", "name_desc"],
          ["Location (a-z)", "location_asc"],
      ]
    end
  end
  </code></pre>
  
  <p>AgentsController/index.html.erb</p>
  
  <pre><code>def index
      @filterrific = initialize_filterrific(
          Agent,
          params[:filterrific],
          select_options: {
              sorted_by: Agent.options_for_sorted_by,
          },
          persistence_id: true,
          default_filter_params: {},
          available_filters: [:sorted_by],
          sanitize_params: true,
          ) || return
  
      @agents = @filterrific.find.paginate(page: params[:page], per_page: 10)
    end
  </code></pre>
  
  <p>index.html.erb</p>
  
  <pre><code>&lt;%= form_for_filterrific @filterrific do |f| %&gt;
    &lt;div&gt;
      Search
      &lt;%= f.text_field(
              :search_query,
              class: 'filterrific-periodically-observed'
          ) %&gt;
    &lt;/div&gt;
    &lt;div&gt;
      Sorted by
      &lt;%= f.select(:sorted_by, @filterrific.select_options[:sorted_by]) %&gt;
    &lt;/div&gt;
    &lt;div&gt;
      &lt;%= link_to(
              'Reset filters',
              reset_filterrific_url,
              ) %&gt;
    &lt;/div&gt;
    &lt;%# add an automated spinner to your form when the list is refreshed %&gt;
    &lt;%= render_filterrific_spinner %&gt;
  &lt;% end %&gt;
  
  &lt;%= render(
          partial: 'agents/list',
          locals: { agents: @agents }
      ) %&gt;
  </code></pre>
  
  <p>_list.html.erb (partial)</p>
  
  <pre><code>&lt;div id="filterrific_results"&gt;
    &lt;table class="table"&gt;
      &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;%= filterrific_sorting_link(@filterrific, :name) %&gt;&lt;/th&gt;
        &lt;th&gt;&lt;%= filterrific_sorting_link(@filterrific, :location) %&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
      &lt;% agents.each do |agent| %&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%= agent.name %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= agent.location %&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;% end %&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;%= will_paginate agents %&gt;
  </code></pre>
  
  <p>logs</p>
  
  <pre><code>Started GET "/agents?filterrific%5Bsorted_by%5D=location_desc" for ::1 at 2020-03-12 16:26:07 +0530
  Processing by AgentsController#index as JS
    Parameters: {"filterrific"=&gt;{"sorted_by"=&gt;"location_desc"}}
    User Load (301.8ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 5], ["LIMIT", 1]]
    ↳ app/controllers/agents_controller.rb:107:in `authenticate_user'
    Rendering agents/index.js.erb
    Agent Load (248.2ms)  SELECT "agents".* FROM "agents" ORDER BY location desc LIMIT $1 OFFSET $2  [["LIMIT", 10], ["OFFSET", 0]]
    ↳ app/views/agents/_list.html.erb:20
    Rendered agents/_list.html.erb (Duration: 255.6ms | Allocations: 1562)
    Rendered agents/index.js.erb (Duration: 268.5ms | Allocations: 5750)
  Completed 200 OK in 585ms (Views: 27.3ms | ActiveRecord: 550.0ms | Allocations: 8947)
  </code></pre>