If I only want to return Proposals that are published but not expired, is this possible with Pundit?
So far, I have this:
class ProposalPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if @user.admin?
scope.all
else
scope.where(published: true)
end
end
end
...
end
One work around is to write extra code in the index
action of my Proposal controller to further filter the list of Proposals instances down to non-expired proposals.
I am hoping there's some magical syntax like this:
scope.where({published: true, expire_date > Time.now })
Any ideas? :D