-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional database caching #20
base: main
Are you sure you want to change the base?
Conversation
@dansingerman @andrewculver would love any feedback from either of you on this change. |
I think this is a good change. I like having the |
Good point @dansingerman. I was actually thinking maybe we should just always enable it. |
I think if it's on by default, then it's not obvious there's caching going on. From a developer experience point of view I'd favour having it off by default, but have the reference implementation include the
Then there is a breadcrumb trail for a developer to follow if they start getting weird permissions issues. |
Makes sense. Unless @andrewculver has any other thoughts at this stage, I'll keep this PR moving forward. |
Adding caching to the Instead, how about adding something like this to the end of
and then in Roles::User
Then you only need to do one update per permit statement, and the code can be a little cleaner because you don't have to pass the cache argument all the way through. |
I like that. |
Yes I think you're right. We'd need that still especially in the case you had a permit statement with In that case the |
Yeah I think given that we're making the cache happen "under the hood" as long as when they set |
@adampal Any chance we can resolve the failing tests? |
@dansingerman after merging #21, using Now that we've introduced caching at two different levels, I think we need to be explicit about each one to avoid confusion. What do you think about changing the method param you introduced in #21 to be So a full permit method call with both levels of caching enabled would look like:
It's a bit long but at least it's explicit and leaves the breadcrumbs we were talking about for developers to discover the caching options. |
Makes sense to me 👍 |
The bullet_train-roles gem requires this module to be included in the User model. We didn't notice it was missing before because we were accidentally overloading the methods it adds in the bullet_train-base gem. We're currently working on an update (bullet-train-co/bullet_train-roles#20) to the roles gem that changes some of the method signatures and breaks the overloaded versions of the methods. I've added another PR to remove the overloaded methods from the bullet_train-base gem here (bullet-train-co/bullet_train-base#121). In order to do the update to the roles gem, we need to remove the overloaded versions of the methods _and_ add the required module in to the User class. We can either add the `Roles::User` module directly to the User class like I've done in this PR, or we could add it into the `Users::Base` module. My feeling is that is should actually go directly into the User class because it demonstrates to developers what they would need to do if they want to add another model to their application that could also have roles. However, I'm happy to move it into the `Users::Base` module instead if you think that's a better place for it (it does keep the User class clean that way!).
@andrewculver there's some upstream changes we need to make to the bullet_train-base gem and the starter repo to get the tests here passing. |
No description provided.