Sharing Query Logic Within ActiveRecord Models

I was recently working on an application in which we had a class method / scope used to return a specific set of users. This was fine and good until we found ourselves needing to capture the same logic at the instance level. Ideally, I was hoping to be able to avoid duplicating the logic, and simultaneously keep things efficient.Users in our application can be configured to receive alerts. We have a class method on the User model used to query for all the users who can receive alerts:.
Sharing Query Logic Within ActiveRecord Models #ruby #rubydeveloper #rubyonrails #activerecord https://rubyonrails.ba/single/sharing-query-logic-within-activerecord-models

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles