Skip to content
This repository was archived by the owner on Nov 19, 2019. It is now read-only.

Using Authority with Dossier reports

Nathan Long edited this page Jun 21, 2013 · 6 revisions

To use Authority with Dossier in a Rails app, you need to do two things:

  1. Configure the reports controller
# config/initializers/dossier.rb
Rails.application.config.to_prepare do
  Dossier::ReportsController.authorize_actions_for :report_class, actions: {multi: :read}
  Dossier::Report.send(:include, Authority::Abilities)
  Dossier::MultiReport.send(:include, Authority::Abilities)
end
  1. Point your reports to an authorizer
class MyAwesomeReport < Dossier::Report
  self.authorizer_name = '::ReportsAuthorizer'
  ...
end

That's it! You can hide report links as usual: if current_user.can_read?(MyAwesomeReport). The controller side is already handled.