class Ransack::Context
def traverse(str, base = @base)
def traverse(str, base = @base) str ||= ''.freeze if (segments = str.split(Constants::UNDERSCORE)).size > 0 remainder = [] found_assoc = nil while !found_assoc && segments.size > 0 do # Strip the _of_Model_type text from the association name, but hold # onto it in klass, for use as the next base assoc, klass = unpolymorphize_association( segments.join(Constants::UNDERSCORE) ) if found_assoc = get_association(assoc, base) base = traverse( remainder.join(Constants::UNDERSCORE), klass || found_assoc.klass ) end remainder.unshift segments.pop end raise UntraversableAssociationError, "No association matches #{str}" unless found_assoc end klassify(base) end