lib/ransack/adapters/mongoid/context.rb in ransack-1.8.4 vs lib/ransack/adapters/mongoid/context.rb in ransack-1.8.6

- old
+ new

@@ -32,11 +32,11 @@ # when :decimal # else # :string name = '_id' if name == 'id' - t = object.klass.fields[name].try(:type) || @bind_pairs[attr.name].first.fields[name].type + t = object.klass.fields[name].try(:type) || bind_pair_for(attr.name).first.fields[name].type t.to_s.demodulize.underscore.to_sym end def evaluate(search, opts = {}) @@ -59,11 +59,11 @@ def attribute_method?(str, klass = @klass) exists = false if ransackable_attribute?(str, klass) exists = true - elsif (segments = str.split(/_/)).size > 1 + elsif (segments = str.split(Constants::UNDERSCORE)).size > 1 remainder = [] found_assoc = nil while !found_assoc && remainder.unshift( segments.pop) && segments.size > 0 do assoc, poly_class = unpolymorphize_association( @@ -109,10 +109,10 @@ def get_parent_and_attribute_name(str, parent = @base) attr_name = nil if ransackable_attribute?(str, klassify(parent)) attr_name = str - elsif (segments = str.split(/_/)).size > 1 + elsif (segments = str.split(Constants::UNDERSCORE)).size > 1 remainder = [] found_assoc = nil while remainder.unshift( segments.pop) && segments.size > 0 && !found_assoc do assoc, klass = unpolymorphize_association(segments.join('_'))