Rails 6.1 adds support to
comparison operator in the
where clause. The four
comparison operators supported are:
- Greater than (>).
- Greater than equal to (>=).
- Less than (<).
- Less than equal to (<=).
The comparison operator
is also supported by the finder
methods in ActiveRecord which
internally uses where clause,
The new style for comparisons has to follow advantages:
whereclause with the comparison operator doesn’t raise an exception when
ActiveRecord::Relationuses ambiguous column name.
whereclause with the comparison operator handle proper precision of the database columns.
Before Rails 6.1, to add a condition with comparison in where clause, we had to add raw SQL notation.
Check out the pull request for more details on this.