Sha256: b1c831cf8729cb9373a6880e42271c50a4b49451d1563fbf2d4c987b133ceb57

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

# BetterAr

BetterAr replaces the .all, .first and .count methods for ActiveRecord.


## Install

Bundler:

    gem 'better_ar'

Command line:

    gem install better_ar

## Usage

Now a single hash can be passed to ActiveRecord::Base.all that contains not only the where values but also other scopes like 'limit' and 'order' and also implicit joins

    User.all(:age => 10, :limit! => 5, :offset! => 10, :order! => :name, :records => {:name => 'test'})

is the same as

    User.joins(:records).where(:age => 10, :records => {:name => 'test'}).limit(5).offset(10).order(:name)

While this may seem less concise the advantage is being able to dynamically construct the query with a single hash in code.

### Legacy

If the params contain :condition it will fall back to the legacy method.

## Other

Brian Cardarella (c) 2011

License: MIT (see MIT-LICENSE.txt)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
better_ar-0.0.6 README.markdown