title: How to pass ransack param[:q] object to another method in rails
body: <p>I am trying to pass my ransack params[:q] object to my presenter class but getting the <code>No Ransack::Search object was provided to search_form_for!</code> error.</p>
  
  <p>Here is my sample code</p>
  
  <p><strong>client_managers_widgets/index.html.haml</strong></p>
  
  <pre><code>= search_form_for @search, :url =&gt; admin_client_managers_widgets_path do |f|
    = render :partial =&gt; "admin/share/filter_wrapper", :locals =&gt; { :f =&gt; f, :filter=&gt; "admin/client_managers_widgets/filters/redemption_filter" }
  </code></pre>
  
  <p><strong>_redemption_filter.html.haml</strong></p>
  
  <pre><code>%table.filters
    %tr
      %td
        = f.label :created_at_gteq, "Select Period"
        = f.select :created_at_gteq, { "Start Till Date" =&gt; "", "This Year" =&gt; Date.today.beginning_of_year, "Last Month" =&gt; 1.month.ago.beginning_of_month, "This Month" =&gt; Date.today.beginning_of_month }
      %td
        = f.label :user_telecom_circle_regional_managers_id_eq, "Region"
        = f.collection_select :user_telecom_circle_regional_managers_id_eq, @telecom_regions.select_options, :id, :region, {:include_blank =&gt; t(:all)}, :class =&gt; 'telecom_circle_regional_managers_id_eq'
    %tr
      %td
        = f.label :created_at_date_gteq,"Select Custome Time"
        = f.text_field :created_at_date_gteq, :class =&gt; 'datepicker input-small'
        = f.label "-", :class=&gt;"to"
        = f.text_field :created_at_date_lteq, :class =&gt; 'datepicker input-small'
  </code></pre>
  
  <p><strong>controller => client_managers_widgets</strong></p>
  
  <pre><code>def index
       @client_manager_dashboard = ClientManagerDashboard.new(current_admin_user, search_params)
       @users = @client_manager_dashboard.get users
     # .
    # .
    # .
  end
  
  private
  
  def search_params
    params[:q]
  end
  </code></pre>
  
  <p><strong>presenter => client_manager_dashboard</strong></p>
  
  <pre><code>class ClientManagerDashboard
    def initialize(admin_user, search_params)
      @current_ability = Ability.new(admin_user)
      @search_params = search_params
    end
  
    def get_users
      @search = User.joins(:client).where(clients: {id: clients}).search(search_params)
      @users = @search.result
    end
    private
  
    def current_ability
      @current_ability
    end
  
    def search_params
      @search_params
    end
  end
  </code></pre>
  
  <p>Right now I just added basic code snippet but it is the generalized scenario.
  Please let me know any one has implemented this type of scenario.</p>