{"action":"closed","issue":{"url":"https://api.github.com/repos/elabs/pundit/issues/305","labels_url":"https://api.github.com/repos/elabs/pundit/issues/305/labels{/name}","comments_url":"https://api.github.com/repos/elabs/pundit/issues/305/comments","events_url":"https://api.github.com/repos/elabs/pundit/issues/305/events","html_url":"https://github.com/elabs/pundit/issues/305","id":100185324,"number":305,"title":"ArgumentError when policy not found","user":{"login":"jaredbeck","id":380809,"avatar_url":"https://avatars.githubusercontent.com/u/380809?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredbeck","html_url":"https://github.com/jaredbeck","followers_url":"https://api.github.com/users/jaredbeck/followers","following_url":"https://api.github.com/users/jaredbeck/following{/other_user}","gists_url":"https://api.github.com/users/jaredbeck/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredbeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredbeck/subscriptions","organizations_url":"https://api.github.com/users/jaredbeck/orgs","repos_url":"https://api.github.com/users/jaredbeck/repos","events_url":"https://api.github.com/users/jaredbeck/events{/privacy}","received_events_url":"https://api.github.com/users/jaredbeck/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-10T22:47:59Z","updated_at":"2015-09-09T18:51:39Z","closed_at":"2015-09-09T18:51:39Z","body":"Given a policy that can't be found, because I forgot to inherit ApplicationPolicy,\r\n\r\n```ruby\r\ndef DerpPolicy # I forgot to inherit ApplicationPolicy\r\nend\r\n```\r\n\r\nand a controller that attempts to find that policy,\r\n\r\n```ruby\r\ndef DerpsController < ApplicationController\r\n  def create\r\n    derp = Derp.new\r\n    authorize derp\r\n  end\r\nend\r\n```\r\n\r\npundit raises an ArgumentError.\r\n\r\n```\r\nArgumentError:\r\n wrong number of arguments (2 for 0)\r\n# [snip]/gems/pundit-1.0.1/lib/pundit.rb:62:in `initialize'\r\n# [snip]/gems/pundit-1.0.1/lib/pundit.rb:62:in `new'\r\n# [snip]/gems/pundit-1.0.1/lib/pundit.rb:62:in `policy!'\r\n# [snip]/gems/pundit-1.0.1/lib/pundit.rb:137:in `policy'\r\n# [snip]/gems/pundit-1.0.1/lib/pundit.rb:115:in `authorize'\r\n# ./app/controllers/derps_controller.rb:4:in `create'\r\n```\r\n\r\nInstead, it would be nice if pundit raised a more helpful error, like PolicyNotFound."}}