I'm a React, Javascript & Rails full-stack Software Engineer. I have been working remotely for the past two years in a remote village. Before joining as a Software Engineer I founded kwiq - a hyperlocal delivery startup to deliver things in remote villages.
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
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.