5

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.

4

2 に答える 2

0

pundit:install generatorを使用して、アプリケーションのデフォルト ポリシー ファイルを生成する必要があります。

rails g pundit:install
  create  app/policies/application_policy.rb
于 2015-03-13T06:21:55.290 に答える