0

I need to create a class method of my ActiveRecord. But that method is not meant to be a scope, so I'd like to prevent misusage of it like a scope. Is it possible to do?

Sergey Potapov
  • 3,819
  • 3
  • 27
  • 46

1 Answers1

1

Like kiddorails hinted, this is not possible. The underlying reason is that AR puts many responsibilities into one class -- validation, persistence, finding/querying. If you really care about encapsulating these methods in one place, then you might consider creating a separate class (which would prevent 'misuse' by nature as it only has query-related methods) that handles just the query-related logic. (There are other strategies one could consider as well, too)

Brian Hahn
  • 438
  • 5
  • 5