class Pundit::PolicyFinder

def param_key

Returns:
  • (String) - the name of the key this object would have in a params hash
def param_key
  model = object.is_a?(Array) ? object.last : object
  if model.respond_to?(:model_name)
    model.model_name.param_key.to_s
  elsif model.is_a?(Class)
    model.to_s.demodulize.underscore
  else
    model.class.to_s.demodulize.underscore
  end
end