lib/jquery/gridify/grid_finder.rb
def current_scope
      #debugger
      find_args = {}
      find_args[:include] = colInclude if colInclude
      if sort_by.present? && col = columns_hash[sort_by]
        if (sort_by.include? ".")
          # Workaround for :include and nested attributes
          field = sort_by.split('.', 2)
          if field.length == 2
            self.sort_by = field[0].pluralize + "." + field[1]
          end
        end
        if case_sensitive || !([:string, :text].include?(col.value_type))
          find_args[:order] = "#{sort_by} #{sort_order}"
        else
          find_args[:order] = "upper(#{sort_by}) #{sort_order}"
        end
      end

      if total_rows.present? && total_rows > 0
        find_args[:limit] = total_rows
        offset = (current_page.to_i-1) * rows_per_page if current_page.present?
        find_args[:offset] = offset if offset && offset > 0
      elsif rows_per_page.present? && rows_per_page > 0
        find_args[:limit] = rows_per_page
        offset = (current_page.to_i-1) * rows_per_page if current_page.present?
        find_args[:offset] = offset if offset && offset > 0
      end

      cond = rules_to_conditions
      find_args[:conditions] = cond unless cond.blank?
      find_args
    end
def current_scope
      #debugger
      find_args = {}
      find_args[:include] = colInclude if colInclude
      if sort_by.present? && col = columns_hash[sort_by]
        if (sort_by.include? ".")
          # Workaround for :include and nested attributes
          field = sort_by.split('.', 2)
          if field.length == 2
            self.sort_by = field[0].pluralize + "." + field[1]
          end
        end
        if case_sensitive || !([:string, :text].include?(col.value_type))
          find_args[:order] = "#{sort_by} #{sort_order}"
        else
          find_args[:order] = "upper(#{sort_by}) #{sort_order}"
        end
      end

      if total_rows.present? && total_rows > 0
        find_args[:limit] = total_rows
        offset = (current_page.to_i-1) * rows_per_page if current_page.present?
        find_args[:offset] = offset if offset && offset > 0
      elsif rows_per_page.present? && rows_per_page > 0
        find_args[:limit] = rows_per_page
        offset = (current_page.to_i-1) * rows_per_page if current_page.present?
        find_args[:offset] = offset if offset && offset > 0
      end

      cond = rules_to_conditions
      find_args[:conditions] = cond unless cond.blank?
      find_args
    end
return find args (scope) for current settings