I am using Pundit to authorize a model in my controller:
@board = authorize Board.find(id)
However, I have a full()
method on my model that calls a mongodb aggregation and returns json. If I try to authorize that I get the error:
unable to find policy 'HashPolicy' for ... (object)
This is because Pundit expects an active_record
model to authorize.
I am currently getting around this my first authorizing the Board.find(id)
, and then making a second db call to get the aggregation. This is obviously impractical.
Is there any way I can get Pundit to accept the json object? Or is there a way for me to get the original object back from my aggregation?