I am building application that currently has a simple authorization requirments:
All users can view the data of all controllers. Only Admin can create/edit the data. The project use admin gem so no controllers in my application (although I can overide if needed) I would like to add authorization for the generic requirement for all controllers:
class ApplicationController < Administrate::ApplicationController
before_filter :authenticate_admin
def authenticate_admin
authorize requested_resource # requested_form is the relevant object(e.g. Post @post)
end
end
but then I get the following:
unable to find scope NilClassPolicy::Scope for NilClass app/policies/application_policy.rb:41:in scope' app/policies/application_policy.rb:15:inshow?' app/controllers/admin/application_controller.rb:27:in `authenticate_admin'
Seems like it can't find the policy, what do you think?