title: Pagination with tire
body: <p>I am looking to use Tire gem for pagination in Elastic Search in my ruby-script but params[:page] is detected as an undefined local variable:</p>
  
  <pre><code>require 'rubygems'
  require 'tire'
  require 'json'
  require 'pp'
  require 'fileutils'
  require 'bigdecimal'
  require 'bigdecimal/util'
  require 'kaminari'
  
  def SearchTesh
  
  def self.aggregate_cost(account_id, start_date, end_date, options)
  
    return nil if options[:tax_query] &amp;&amp; options[:total_query] # both can't be true
    if options[:tax_query] || options[:total_query] #strip day (keep only month) if either is true
      start_date,end_date = start_date[0...-3], end_date[0...-3]
    end
  
    query_string = "PayerAccountId:\"#{account_id}\" AND UsageStartDate:[#{start_date} TO #{end_date}]"
    opt = { :page =&gt; (params[:page] || 1), :size =&gt; 100 }
    search_results = Tire.search '*', opt do
      query { string "#{query_string}" }
      from opt[:size].to_i * (opt[:page].to_i-1)
    end
    return nil if search_results.blank?
    aggregated_results = parse_search_result(
        search_results, {tax_query: options[:tax_query], total_query: options[:total_query]})
    return aggregated_results
   end
  end
  </code></pre>
  
  <p>This is my function and at the line:
  <code>opt = { :page =&gt; (params[:page] || 1), :size =&gt; 100 }</code>
  the following error comes up:</p>
  
  <blockquote>
    <p>tasks/test_search.rb:27:in <code>aggregate_cost': undefined local variable or method</code>params' for SearchTest:Class (NameError)</p>
  </blockquote>