Police controls
# avo-2
f
Hi, is there a way to hide the edit/delete buttons on an index view?

https://cdn.discordapp.com/attachments/740893011994738751/1130812947439034459/Screenshot_2023-07-18_at_12.46.14.png

l
Hello @future-author-97799 yes there is, you can achieve that behavior using policies
f
act_on_delete ?
l
No
act_on?
is used for rendering the action list that appear on top of panels
f
I still want the user to be able to use the delete action, but only from the Show page
not from the index
l
you want
destroy?
and
edit?
/
update?
got it
f
destroy
l
give me 2 minutes
inside the
destroy?
method you can access the
view
variable and make a condition to be visible only on show
f
oh yes, perfect! thank you
l
Anytime!
f
is there any doc on how to access this variable?
l
Hmm actually I was searching for it to send you but I don't find it, i think we missed that out
f
OK np. I tried to use the local var
view
but did not work
l
view is not defined inside
destroy?
??
l
I think it's not available
that's evaluated in the Pundit context, not something we evaluate ourselves
not sure if we can push new vars into pundit methods. I'd love to be able to do that though
I might be wrong, as Paul hints at me
😛
I'm gonna let @loud-jewelry-99127 take over here 🙂
f
wise, according to the thread name 🙂
l
:))
l
@future-author-97799 , @lemon-wall-20836 i'm not sure what happened... I tested this on the dummy app of Avo and i got acces on view, resource and a bunch of other variables inside police methods... Now, after i restarted the server i only can acces the record and the user... Not sure what happened
i thnk you're right 😦
l
I think there's some kind of caching going on with the context in which it's evaluated at some point
I would look into how we could support that officially
l
Sry for missleading you, not sure why on my end i had acces to a bunch of variables
f
No problem