varvet / pundit

Minimal authorization through OO design and pure Ruby classes
MIT License
8.22k stars 625 forks source link

Add `policy_class` parameter to `permitted_attributes` function #742

Open evgenyneu opened 1 year ago

evgenyneu commented 1 year ago

Is it possible to add policy_class parameter to permitted_attributes function (similar to authorise)?

So I can call:

permitted_attributes(@post, :update, policy_class: MyPolicy)

This is necessary for my code where the name of the policy and record class are different.

Merovex commented 8 months ago

Should this be closed?

hobbypunk90 commented 8 months ago

@Merovex sorry, that was my vault :sweat_smile: i cleaned my github a bit too fast... :sweat_smile:

Burgestrand commented 3 months ago

Knee-jerk reaction is yes!

A bit worried about the caching behaviour in this case. We could probably bypass the cache just we're already doing it in the other methods.

My main worry is that I'm not confident the cache behaviour as it is is a good behaviour, and we'd be spreading it. At least it would be somewhat consistent in itself though.