-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Loading rules from a JSON file does not work when following the documentation #177
Comments
Some example would be helpful |
Of the code? All the code is doing is converting JSON rules to Javascript objects and passing them to Ability. There is no difference between the rules created with DSL and JSON. That was the frustrating part. |
That is the code I shared above... |
@nidkil You can edit the description of the issue and describe what was the difference, because it's hard to track issues that have no proper description. |
What happened to the discription!?!?!?!? |
For some strange reason the discription was not saved. Sorry. Should be visible now. |
It is |
|
Hi Stalniy, I did not see this description before. It is clear. No need to rephrase it. |
Ok, closing this |
I was changing the setup of the ability rules from DSL to loading them from a JSON file. To setup the initialization from JSON I was following the section
Store ability templates
in the documentation here.Loading the rule templates from the JSON file, initializing the template variables and passing them to Ability worked fine. But once I started checking the rules they did not work as expected. I compared the DSL version to the JSON version using console.log(ability.rules) and could not find any difference.
It turns out the there was a difference between the way the DSL and JSON version were being initialized.
In the DSL version I was following a Medium post by Sergii, which initialized the rules in the following way:
This is the subjectName function:
In the JSON template version I was following the section
Store ability templates
from the documentation here, which was initializing the rules without the subjectName:After adding
subjectName
to the initialization the rules are working as expected. I do not really understand whatsubjectName
is doing. Could you please explain?Should the documentation be updated?
The text was updated successfully, but these errors were encountered: