vendor/plugins/searchgasm-1.0.2/lib/searchgasm/search/ordering.rb
# Determines by what columns the search is being ordered. This is nifty in that is reverse engineers the order SQL to determine this, only
# if you haven't explicitly set the order_by option yourself.
Determines by what columns the search is being ordered. This is nifty in that is reverse engineers the order SQL to determine this, only
if you haven't explicitly set the order_by option yourself.
Determines by what columns the search is being ordered . This is nifty in that is reverse engineers the order SQL to determine this only if you haven ' t explicitly set the order_by option yourself .
def order_by
        return @order_by if @order_by
        if !order.blank?
          order_parts = order.split(",").collect do |part|
            part.strip!
            part.gsub!(/ (ASC|DESC)$/i, "").gsub!(/(.*)\./, "")
            table_name = ($1 ? $1.gsub(/[^a-z0-9_]/i, "") : nil)
            part.gsub!(/[^a-z0-9_]/i, "")
            reflection = nil
            if table_name && table_name != klass.table_name
              reflection = klass.reflect_on_association(table_name.to_sym) || klass.reflect_on_association(table_name.singularize.to_sym)
              next unless reflection
              {reflection.name.to_s => part}
            else
              part
            end
          end.compact
          order_parts.size <= 1 ? order_parts.first : order_parts
        else
          klass.primary_key
        end
      end
def order_by return @order_by if @order_by if ! order . blank? order_parts = order . split ( "," ) . collect do | part | part . strip! part . gsub! ( /  (ASC|DESC)$ /i , "" ) . gsub! ( / (.*) \. / , "" ) table_name = ( $1 ? $1 . gsub ( / [^a-z0-9_] /i , "" ) : nil ) part . gsub! ( / [^a-z0-9_] /i , "" ) reflection = nil if table_name && table_name != klass . table_name reflection = klass . reflect_on_association ( table_name . to_sym ) || klass . reflect_on_association ( table_name . singularize . to_sym ) next unless reflection { reflection . name . to_s => part } else part end end . compact order_parts . size <= 1 ? order_parts . first : order_parts else klass . primary_key end end
Determines by what columns the search is being ordered.
Determines by what columns the search is being ordered .
# Reversege engineer order, only go 1 level deep with relationships, anything beyond that is probably excessive and not good for performance