Rails 6 has added
This allows us to change the previously added fields in
Rails already has rewhere
on Active Record Relation.
Using them we can override existing
order clauses on a
Similarly if one had to select different fields per query,
one would have to do that on a new scope of the Relation.
In an existing application, we can’t always pass scope around.
We may have scopes, that already consist of the
reselect now allows us to override the existing select clause:
This is a short-hand for
Reselect unscopes the entire
and replaces it with new select clause.
Changes in SQL
We can take a look at how the SQL changes with