aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-06-02 22:45:30 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-06-02 22:45:30 +0200
commitdb515c7ca16a1047505653e45369134e00eb2204 (patch)
treea6f092c73fb5908a2a39ce5ce62652881861e503
parent226ebbcb8679aea13eba726e67086a07070265c1 (diff)
downloadhmnoweb-db515c7ca16a1047505653e45369134e00eb2204.tar.gz
hmnoweb-db515c7ca16a1047505653e45369134e00eb2204.tar.bz2
hmnoweb-db515c7ca16a1047505653e45369134e00eb2204.zip
Monkeypatch will_paginate to work with ruby 2.5.5.
-rw-r--r--config/initializers/will_paginate_fix.rb27
1 files changed, 27 insertions, 0 deletions
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