Skip to content

Commit

Permalink
Merge pull request #45617 from ajporterfield/add-beginless-range-exam…
Browse files Browse the repository at this point in the history
…ple-to-ar-querying-guide

Add endless range example to the Active Record Querying guide [ci-skip]

(cherry picked from commit bc0f07b)
  • Loading branch information
jonathanhefner committed Jul 24, 2022
1 parent 196e0f7 commit 77f1641
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions guides/source/active_record_querying.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,18 @@ SELECT * FROM books WHERE (books.created_at BETWEEN '2008-12-21 00:00:00' AND '2

This demonstrates a shorter syntax for the examples in [Array Conditions](#array-conditions)

Beginless and endless ranges are supported and can be used to build less/greater than conditions.

```ruby
Book.where(created_at: (Time.now.midnight - 1.day)..)
```

This would generate SQL like:

```sql
SELECT * FROM books WHERE books.created_at >= '2008-12-21 00:00:00'
```

#### Subset Conditions

If you want to find records using the `IN` expression you can pass an array to the conditions hash:
Expand Down

0 comments on commit 77f1641

Please sign in to comment.