question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Really hard to grasp the concepts as a newbie

See original GitHub issue

Hi there! I really want to use CASL for my app, i’ve read the docs and examples multiple times, but i pretty much have no idea how to use it exactly.

What i don’t get especially is: What exactly are things like ‘read’ and ‘all’ ? where/how are they defined? how can i define them myself?

if i want to give users the ability to delete a post and display a button if they can… like can('delete', 'post') how does CASL know what ‘delete’, ‘post’ and ‘button’ are? it has to be defined somewhere, but i haven’t found out where. probably it’s related to db-query verbs, but then again there are cases where it can’t be just translated to CRUD, right? it seems to “just work” in all the examples i have seen. so basically i have no idea how to translate that to my app, where i have to customize that.

is there a beginner-friendly explanation somewhere that i have overlooked? something that covers the absolute basics? sorry if this seems stupid, i just can’t get my head around it it seems 😕

regards 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
GsHericommented, Dec 21, 2018

Hi there and thanks very much for your reply 😃 it’s nice to have that kind of support 😃

My stack is pretty basic: Vue 2.5.16, vuex 2.4.0, vuetify 1.2.5, for now i’m working with a mock backend that’s supposed to return an array of roles for the user like roles: [‘admin’, ‘mod’]. my problem is: how can i translate those roles to abilities? how exactly do i define anything? I want to merge the abilities of the provided roles, which is (as far as i understood) the way it is supposed to work with CASL. I’ve set up an ability.js with const admin etc., but now i’m stuck at “how does CASL know what i mean when i define 'can(‘edit’, ‘chatMessage’) or similar”

like i said, all the articles and docs seem to be assuming that part is already understood by everyone 😄 but i’m having a hard time. i’ve read most of the articles and examples you mentioned, but they didn’t help very much. all i ever see is “easy, just install casl, write a bunch of can(‘this’, ‘that’), and everything works!”. But i’m pretty sure that’s not how it works 😄 I thought there might be a youtube video visualizing the concepts, but there seems to be none as well.

so i’ll probably just need a more abstract visualization of how everything is connected, how and where things are defined and how it plays together.

thanks again very much 😃

2reactions
stalniycommented, Jan 10, 2019

You need to update your existing ability instance by rules from each role. The example in docs is more for backend but you can check example for vue integration with vuex and api: https://github.com/stalniy/casl-vue-api-example

Thanks for the issue, I close this and will plan an update in docs (#144)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I find it difficult to grasp any concept?
Your mind probably has not been prepared to grasp concepts. It requires a bit of study, and much that you need to know...
Read more >
8 Powerful Tricks That Make You Grasp New Concepts ...
1) Use mental associations · 2) Apply the 80/20 principle · 3) Break it down · 4) Write it down · 5) Connect...
Read more >
I understand concepts but have difficulty applying or coding ...
It's best to really really understand the concepts backwards and forwards. Memorize them even if it feels like you're blindly memorizing the ...
Read more >
Why is Rust difficult? - Vorner's random stuff - GitHub Pages
One of the problems why I found Rust hard to learn was that it looked similar to other imperative languages on one side,...
Read more >
How to Learn Programming?
Tutorials are fantastic and it teaches a lot of concepts or different ... Learning the first language is difficult for most of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found