Skip to content

Instantly share code, notes, and snippets.

@be9
Created December 29, 2008 15:51
Show Gist options
  • Save be9/41293 to your computer and use it in GitHub Desktop.
Save be9/41293 to your computer and use it in GitHub Desktop.
class Blah < ApplicationController
access_control do
default :deny
allow anonymous # аналогично allow nil - пустить анонима
allow :admin # проверяет по глобальной роли
allow :creator, :of => Ruby # проверяет по роли на класс
allow :employed, :by => :company # current_user.has_role? :employed, @company
allow do
current_user.has_role?('lover', Dog) && current_user.has_role?('hater', Cat)
end
# аналог того что выше
allow possessor_of_several_roles do
role :lover, :of => Dog
role :hater, :of => Cat
end
allow :known_guy, :to => :index
allow :owner, :of => :site, :to => [:update, :delete, :destroy]
allow anonymous, :except => [:edit, :delete, :update, :destroy, :new]
actions :index, :show do
allow :secretaries
end
actions :edit, :new, :update, :destroy, :delete do
allow :admins
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment