2 minute read
ActiveRecord::QueryMethods are methods provided by Rails to build
and execute database queries.
The select method allows us to select specific fields from the database.
The reselect method in ActiveRecord allows us to change the previously set select statement.
Under the hood, reselect is short-hand for unscope(:select).select(fields). Basically we’re unscoping the entire select statement.
Before 7.1, we were able to reselect specific fields with column names as an array of strings or symbols, or we can provide raw SQL.
But to select the columns from an associated model, we only have the option to provide raw SQL.