diff --git a/lib/bootstrap_pagination/action_view.rb b/lib/bootstrap_pagination/action_view.rb index 15b1649..491f679 100644 --- a/lib/bootstrap_pagination/action_view.rb +++ b/lib/bootstrap_pagination/action_view.rb @@ -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 diff --git a/lib/bootstrap_pagination/fix_symbolize_update.rb b/lib/bootstrap_pagination/fix_symbolize_update.rb new file mode 100644 index 0000000..1ebaba4 --- /dev/null +++ b/lib/bootstrap_pagination/fix_symbolize_update.rb @@ -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