lib/scaffolding_extensions/model/active_record.rb
def scaffold_get_objects(options)
    records = self
    if options[:include]
      records = records.includes(*options[:include])
      records = records.references(*options[:include]) if scaffold_use_references
    end
    records = records.order(*options[:order]) if options[:order]
    records = records.limit(options[:limit]) if options[:limit]
    records = records.offset(options[:offset]) if options[:offset]
    conditions = options[:conditions]
    if conditions && Array === conditions && conditions.length > 0
      if String === conditions[0]
        records = records.where(*conditions)
      else
        conditions.each do |cond|
          next if cond.nil?
          records = case cond
            when Hash, String then records.where(cond)
            when Array then records.where(*cond)
            when Proc then records.where(&cond)
          end
        end
      end
    end
    records.to_a
  end
# Retrieve multiple objects given a hash of options
Retrieve multiple objects given a hash of options
Retrieve multiple objects given a hash of options
def scaffold_get_objects(options)
    records = self
    if options[:include]
      records = records.includes(*options[:include])
      records = records.references(*options[:include]) if scaffold_use_references
    end
    records = records.order(*options[:order]) if options[:order]
    records = records.limit(options[:limit]) if options[:limit]
    records = records.offset(options[:offset]) if options[:offset]
    conditions = options[:conditions]
    if conditions && Array === conditions && conditions.length > 0
      if String === conditions[0]
        records = records.where(*conditions)
      else
        conditions.each do |cond|
          next if cond.nil?
          records = case cond
            when Hash, String then records.where(cond)
            when Array then records.where(*cond)
            when Proc then records.where(&cond)
          end
        end
      end
    end
    records.to_a
  end
def scaffold_get_objects ( options ) records = self if options [ :include ] records = records . includes ( * options [ :include ] ) records = records . references ( * options [ :include ] ) if scaffold_use_references end records = records . order ( * options [ :order ] ) if options [ :order ] records = records . limit ( options [ :limit ] ) if options [ :limit ] records = records . offset ( options [ :offset ] ) if options [ :offset ] conditions = options [ :conditions ] if conditions && Array === conditions && conditions . length > 0 if String === conditions [ 0 ] records = records . where ( * conditions ) else conditions . each do | cond | next if cond . nil? records = case cond when Hash , String then records . where ( cond ) when Array then records . where ( * cond ) when Proc then records . where ( & cond ) end end end end records . to_a end
Retrieve multiple objects given a hash of options
Retrieve multiple objects given a hash of options
options