I have a class method where I want to change the records that are currently captured by the ActiveRecord::Relation object. But I don't know how to access the current scope in a class method. self does not do this.
Example:
class User < ActiveRecord::Base ... def self.modify_those_records
I would use it as follows:
User.some_scope.modify_those_records
So User.some_scope will return to me ActiveRecord::Relation , which contains a bunch of User entries. Then I want to change these entries in this class method and then return them.
The problem is this: I don’t know how to explicitly refer to “this group of records” inside the class method.
source share