AlecStewart1#1125
AEAsh Elixir
•Created by AlecStewart1#1125 on 11/29/2023 in #support
Simple policy checks based with relationships
Hello, friends!
So on the website documentation, we have an example of a simple policy check:
All well and good, but in a more real world example we'd probably have:
- Roles for Users
- Many permissions for those roles
- Potentially many permissions for users
So let's say we have something like the following:
A
User
resource:
And you want to check both the role, the permissions a role has and user permissions.
My question would be how do we go about doing the simple policy checks when we have a role-permission setup like this? Because the check itself isn't complex, it's more of a "how do we get there" question.6 replies
AEAsh Elixir
•Created by AlecStewart1#1125 on 6/6/2023 in #support
Aggregates with resource relationships
Hello!
So maybe there's something I'm not quite understanding from the documentation, but say I have a State and City. A state can have many cities, so:
And a city belongs to a state:
Now for a state, say I want an aggregate for the number of cities in the state. Do I have an
aggregates
block like the following?
Also, could this be a oneliner as just count :number_of_cities, :cities
? No do ... end
?
Thanks!25 replies
AEAsh Elixir
•Created by AlecStewart1#1125 on 2/27/2023 in #support
Ash Way of Doing Password Hashing and Storage for Phoenix.
So
mix phx.gen.auth
will give you the some of the following in your_app/lib/your_app/accounts/user.ex
:
This seems like the most straightforward way when starting a Phoenix app that has users. Phoenix generates a lot of other private functions for user auth, so for Ash do you create a new module to reference and use similar functions for validate
/change
blocks?22 replies
AEAsh Elixir
•Created by AlecStewart1#1125 on 2/22/2023 in #support
Compile error: module Any is reserved and cannot be defined
Say I have the following resources:
City:
State:
Region:
Credo seems to complain about state, saying:
Not really sure what to do about that.
20 replies