Skip to content

Instantly share code, notes, and snippets.

@mjc-gh
Last active August 17, 2016 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjc-gh/0f2d43102b6ecfb2edaa1db82a84c618 to your computer and use it in GitHub Desktop.
Save mjc-gh/0f2d43102b6ecfb2edaa1db82a84c618 to your computer and use it in GitHub Desktop.
Simon Says Authorizer
class ApplicationController < ActionController::Base
include SimonSays::Authorizer
self.default_authorization_scope = :current_user
end
class DocumentsController < ApplicationController
authenticate :user
find_and_authorize :documents, :edit, through: :memberships, only: [:edit, :update]
find_and_authorize :documents, :delete, through: :memberships, only: :destroy
end
class ReportsController < ApplicationController
authorize_resource :admin, :support
find_resource :report, from: :current_admin, except: [:index, :new, :create]
end
resources :documents
resources :reports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment