Skip to content

Commit

Permalink
arel: update
Browse files Browse the repository at this point in the history
  • Loading branch information
rstacruz committed Nov 23, 2015
1 parent 4907f96 commit a7b94b0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions arel.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ title: Arel

```rb
users = Arel::Table.new(:users)
users = User.arel_table # ActiveRecord model
```

### Fields
Expand Down Expand Up @@ -50,3 +51,20 @@ users.project(users[:age].sum) # .average .minimum .maximum
users.project(users[:id].count)
users.project(users[:id].count.as('user_count'))
```

### `order`

```rb
users.order(users[:name])
```

### With ActiveRecord

```rb
User.arel_table
User.where(id: 1).arel
```

## Reference

* <http://github.com/rails/arel>

0 comments on commit a7b94b0

Please sign in to comment.