Module: Kaminari::Helpers::SinatraHelpers::HelperMethods

Defined in:
lib/kaminari_patch.rb

Instance Method Summary collapse

Instance Method Details

#paginate(scope, options = {}, &block) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/kaminari_patch.rb', line 38

def paginate(scope, options = {}, &block)
  current_path = env['REQUEST_PATH'] rescue nil
  current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {}
  paginator = Kaminari::Helpers::Paginator.new(
    ActionViewTemplateProxy.new(:current_params => current_params, :current_path => current_path, :param_name => options[:param_name] || Kaminari.config.param_name),
    options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
  )
  paginator.to_s
end