From db515c7ca16a1047505653e45369134e00eb2204 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 2 Jun 2021 22:45:30 +0200 Subject: Monkeypatch will_paginate to work with ruby 2.5.5. --- config/initializers/will_paginate_fix.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 config/initializers/will_paginate_fix.rb diff --git a/config/initializers/will_paginate_fix.rb b/config/initializers/will_paginate_fix.rb new file mode 100644 index 0000000..c4003bb --- /dev/null +++ b/config/initializers/will_paginate_fix.rb @@ -0,0 +1,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? Fixnum + attributes[:rel] = rel_value(target) + target = url(target) + end + attributes[:href] = target + tag(:a, text, attributes) + end + end + end +end -- cgit v1.2.3