Permits configuration
kristianmandrup edited this page Apr 15, 2012
·
2 revisions
The Permits system is a CanTango "engine" (not to be confused with Rails engines). Here the engine simply means an executable system used by CanTango to enforce authorization rules.
The cantango-permit_store is yet another CanTango engine. You can even write and plug-in your own engines.
The Permits engine can be configured as any other CanTango Engine:
Use the on!
and off!
methods to enable to disable use of the engine.
Use the mode=
to set the execution mode.
You can register multiple execution modes and override the default :cache, :no_cache modes if you like.
CanTango.config.engine(:permits) do |engine|
# toggle engine on/off
engine.on!
engine.on?
engine.off!
puts engine.modes.valid # => [:cache, :no_cache, :both]
# set execution modes
engine.modes.register :cache, :no_cache
puts engine.modes.registered # => [:cache, :no_cache]
end
See cantango-config
Turn on/off: Enable and disable types of permits and specific permits
CanTango.config.permits do |permits|
# which types of permits to enable
permits.types.enable :user_type, :account_type
permits.enable_all_for :account_type
permits.types.disable :user_type, :account_type
permits.disable_for :user_type, :admin, :editor
end