Scoping allows us to make use of commonly-used queries which can be referenced as method calls on the association objects or models,
The general expectation is that all scope bodies should return an ActiveRecord::Relation or nil. As a result of this, it makes it easy to call other ActiveRecord methods on it. Simply put, a scope is just a custom chain of active record methods. They are sets of pre-defined queries that can be chained to build other complex Queries.
-
Default scopes take the name default_scope when defined in the model and, they are scopes that are applied across all queries to the model in question.
-
When it comes to which scope type to use, please avoid using default_scopes https://dev.to/lewuathe/why-we-should-avoid-defaultscope-in-rails-3ofo