lib/ransack/adapters/active_record/3.0/context.rb
# Because the AR::Associations namespace is insane
Because the AR::Associations namespace is insane
Because the AR :: Associations namespace is insane
def attribute_method?(str, klass = @klass)
          exists = false
          if ransackable_attribute?(str, klass)
            exists = true
          elsif (segments = str.split(/_/)).size > 1
            remainder = []
            found_assoc = nil
            while !found_assoc && remainder.unshift(segments.pop) &&
              segments.size > 0 do
              assoc, poly_class = unpolymorphize_association(
                segments.join(Constants::UNDERSCORE)
                )
              if found_assoc = get_association(assoc, klass)
                exists = attribute_method?(
                  remainder.join(Constants::UNDERSCORE),
                  poly_class || found_assoc.klass
                  )
              end
            end
          end
          exists
        end
def attribute_method? ( str , klass = @klass ) exists = false if ransackable_attribute? ( str , klass ) exists = true elsif ( segments = str . split ( / _ / ) ) . size > 1 remainder = [ ] found_assoc = nil while ! found_assoc && remainder . unshift ( segments . pop ) && segments . size > 0 do assoc , poly_class = unpolymorphize_association ( segments . join ( Constants :: UNDERSCORE ) ) if found_assoc = get_association ( assoc , klass ) exists = attribute_method? ( remainder . join ( Constants :: UNDERSCORE ) , poly_class || found_assoc . klass ) end end end exists end
Because the AR::Associations namespace is insane
Because the AR :: Associations namespace is insane
str
klass