Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[WIP] AC::Parameters is no longer inherited from Hash in Rails 5

Rails commit rails/rails@14a3bd5 began a
series of changes that might affect many apps/gems and cause subtle
bugs.

This commit is a start to Ransack adapting to these changes.
commit ceafc0586a6929aa578ac0b1ad1f7c75219ca4c6 1 parent 456b75e
@jonatack jonatack authored
Showing with 10 additions and 2 deletions.
  1. +7 −2 lib/ransack/helpers/form_helper.rb
  2. +3 −0  lib/ransack/search.rb
View
9 lib/ransack/helpers/form_helper.rb
@@ -79,7 +79,7 @@ def url(routing_proxy, options_for_url)
class SortLink
def initialize(search, attribute, args, params)
@search = search
- @params = params
+ @params = parameters_hash(params)
@field = attribute.to_s
@sort_fields = extract_sort_fields_and_mutate_args!(args).compact
@current_dir = existing_sort_direction
@@ -113,6 +113,11 @@ def html_options(args)
private
+ def parameters_hash(params)
+ return params unless params.instance_variable_defined?(:@parameters)
+ params.instance_variable_get(:@parameters)
+ end
+
def extract_sort_fields_and_mutate_args!(args)
return args.shift if args[0].is_a?(Array)
[@field]
@@ -133,7 +138,7 @@ def search_and_sort_params
end
def search_params
- @params[@search.context.search_key].presence || {}
+ parameters_hash(@params[@search.context.search_key]).presence || {}
end
def sort_params
View
3  lib/ransack/search.rb
@@ -15,6 +15,9 @@ class Search
:translate, :to => :base
def initialize(object, params = {}, options = {})
+ if params.instance_variable_defined?(:@parameters)
+ params = params.instance_variable_get :@parameters
+ end
if params.is_a? Hash
params = params.dup
params.delete_if { |k, v| [*v].all?{ |i| i.blank? && i != false } }
Please sign in to comment.
Something went wrong with that request. Please try again.