Sha256: 05c106638199221b8a3523155e85a80c0972022e2885011e482e60c22c9a3356

Contents?: true

Size: 667 Bytes

Versions: 5

Compression:

Stored size: 667 Bytes

Contents

# add `:no_uri` options to skip query params in pagination urls
require 'will_paginate/view_helpers/action_view'

WillPaginate::ViewHelpers.pagination_options[:no_uri] = false
WillPaginate::ActionView::LinkRenderer.class_exec do
  def url(page)
    @base_url_params ||= begin
      url_params = merge_get_params(default_url_params)
      merge_optional_params(url_params)
    end

    url_params = @base_url_params.dup
    add_current_page_param(url_params, page)
    url_params[param_name.to_sym] = nil if url_params[param_name.to_sym].to_i < 2

    link = @template.url_for(url_params)
    @options[:no_uri] ? link.split('?').first : link.sub(/\?\z/, '')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ab_admin-0.8.3 lib/ab_admin/hooks/will_paginate_no_uri.rb
ab_admin-0.8.2 lib/ab_admin/hooks/will_paginate_no_uri.rb
ab_admin-0.8.1 lib/ab_admin/hooks/will_paginate_no_uri.rb
ab_admin-0.8.0 lib/ab_admin/hooks/will_paginate_no_uri.rb
ab_admin-0.7.0 lib/ab_admin/hooks/will_paginate_no_uri.rb