You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@TheBlackArroVV in fact, there are no big differences between scopes and class methods which returns an ActiveRecord relation. So here I just agree with Aleks that we should avoid using multiline lamda calls for esthetic and readability purposes
Just a question: when should we prefer to use rails scope and where class methods?
These are almost similar things ( one different. That if the lambda (or logic) returns nil, scope returns the current value in this, class method returns nil) See https://www.justinweiss.com/articles/should-you-use-scopes-or-class-methods/
Usually, I use the rule. I prefer to use
scope
for subqueries, but move it to class methods if it needs to usedo end
blockYour thoughts?
The text was updated successfully, but these errors were encountered: