aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers/will_paginate_fix.rb
blob: b41484af85a196f1bc34b1acac8ae989ea57d1fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Monkeypatch will_paginate to work with ruby 2.5.5
module WillPaginate
  module ViewHelpers
    class LinkRenderer # < LinkRendererBase
      def to_html
        html = pagination.map do |item|
          item.is_a?(Integer) ?
            page_number(item) :
            send(item)
        end.join(@options[:link_separator])

        @options[:container] ? html_container(html) : html
      end

      private

      def link(text, target, attributes = {})
        if target.is_a? Integer
          attributes[:rel] = rel_value(target)
          target = url(target)
        end
        attributes[:href] = target
        tag(:a, text, attributes)
      end
    end
  end
end