Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/bootstrap_pagination/action_view.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
require "will_paginate/view_helpers/action_view"
require "bootstrap_pagination/bootstrap_renderer"

# TODO: Remove when will be fixed in will-paginate
if defined?(ActionController::Parameters)
require "bootstrap_pagination/fix_symbolize_update"
end

module BootstrapPagination
# A custom renderer class for WillPaginate that produces markup suitable for use with Twitter Bootstrap.
class Rails < WillPaginate::ActionView::LinkRenderer
include BootstrapPagination::BootstrapRenderer

if defined?(ActionController::Parameters)
include BootstrapPagination::FixSymbolizeUpdate
end
end
end
18 changes: 18 additions & 0 deletions lib/bootstrap_pagination/fix_symbolize_update.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module BootstrapPagination
module FixSymbolizeUpdate
def symbolized_update(target, other)
other.each do |key, value|
key = key.to_sym
existing = target[key]

is_params = lambda { |obj| obj.is_a?(Hash) || obj.is_a?(ActionController::Parameters) }

if is_params.call(value) and (is_params.call(existing) or existing.nil?)
symbolized_update(existing || (target[key] = {}), value)
else
target[key] = value
end
end
end
end
end