I've installed the gem Pundit in my Rails app, and have followed the instructions in the README carefully.
However, when I use authorize in any of my controllers, I get the error message "undefined method 'authorize' for .
Also, when I try to use "policy" in a view, I get the error "undefined method 'policy'".
It's as if Pundit weren't installed at all!
I've included Pundit in my Application Controller.
I have an ApplicationPolicy file with all of my policies, then policy files for each type of record that inherit from the Application Policy.
For some reason, I can't paste any of my code into this question, so I'm hoping I've included enough information!
I'd appreciate any thoughts.
include Pundit
the first line below theApplicationController
declaration. Also, are your controllers inheriting from theApplicationController
? – nikkon226authorize
that conflicts with Pundit. In my application controller, I have thisalias_method :require_login, :authorize
and the next line is myinclude Pundit
. Also, ensure that you are calling authorize on an instance of a model (i.e.,authorize @my_var
) – craig.kaminskyrequire 'pundit'
in the namespaced ApplicationController – Gregor