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

Using authority on controllers that don't have a resource

nathanl edited this page Aug 28, 2012 · 5 revisions

If you need to use Authority on a controller that has no resource, you can use an authorizer directly.

class SiteController < ApplicationController
  authorize_actions_for SiteAuthorizer, :actions => {:home => 'read'}
 
  def home
  end

end

...such as:

class SiteAuthorizer < ApplicationAuthorizer
  def self.readable_by?(user)
    user.has_moustache?
  end
end