Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

[QUESTION] About scopes #16

@gosukiwi

Description

@gosukiwi

Hi guys! I apologize in advance if this is out of place (feel free to close this issue if that's the case) but I do have some questions about Clean Architecture and the way it's implemented here.

I am personally trying to wrap my head around Clean Architecture, and while it sounds great in theory, taking it to practice is quite hard.

My first question is, is it a demo app somewhere I can see? :)

My other question is about scopes. What I understand to be the goal of CA (or at least one of it's goals) is to move the domain logic to it's own place, independent of Rails, Sinatra, the CLI or whatever you use to deliver your app.

That sounds great and all, but I found ActiveRecord to be so closely tied to Rails-land that it's really hard to abstract it away. Particularly for reading complex data/queries.

For example, one blocker I have are scopes. To define scopes (say, Admins can see all Post entities but Users can see only those where(published: true)) you need to a way to filter the results from the database (ActiveRecord::Relation most likely) on the domain-side somehow.

Is there a way to use scopes with this implementation? For example, implementing a use case FindHotStories where it returns the last 10 hot stories where publish is true if you are a regular user, and just all the stories if you are an admin.

Thanks for your time 😄

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions