Scopes
Scopes are a way of preventing users from seeing entities through index routes that they shouldn't. They can be consisted of multiple Scope Items that define rules of who
can see what
.
#
Creating scope itemsScope Items can be created by sending a POST
request to /api/todos/scope_items
.
If we wanted to limit regular users seeing only TODOs that are assigned to them, we can create a Scope Item like this:
Creating additional Scope Items results in them being aggregated using OR
operation, while all of the items defined under the who
and what
arrays of the one Scope Item are separately aggregated using AND
.
#
Updating scope itemsUpdating Scope Items works in a similar way. Just send a PUT
request to /api/todos/scope_items/:id
with the same format of the JSON body.
#
Listing all scope itemsYou can fetch all created Scope Items by sending a GET
request to /api/todos/scope_items
.