diff options
| author | Kir | 2011-11-17 14:35:45 +0400 |
|---|---|---|
| committer | Kir | 2011-11-17 14:35:45 +0400 |
| commit | abcb2bf3ec5adfd5111049d2dd15093e3917041f (patch) | |
| tree | d18da24411ca619b2dd33212e2a3d41a473dfb2e /lib | |
| parent | 668fde12b58214c3cfa8721958e6c29af0e57423 (diff) | |
| download | inboxes-abcb2bf3ec5adfd5111049d2dd15093e3917041f.tar.bz2 | |
Switched to CanCan
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/inboxes/ability.rb | 24 | ||||
| -rw-r--r-- | lib/inboxes/engine.rb | 5 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/inboxes/ability.rb b/lib/inboxes/ability.rb new file mode 100644 index 0000000..18fca88 --- /dev/null +++ b/lib/inboxes/ability.rb @@ -0,0 +1,24 @@ +module Inboxes + class InboxesAbility + include CanCan::Ability + + def initialize(user) + # Discussion + can [:index, :create], Discussion + can :read, Discussion do |discussion| + discussion.can_participate?(user) + end + + # Message + # can :create, Message do |message| + # message.discussion.can_participate?(user) + # end + # + # # Speaker + # can [:create, :destroy], Speaker do |speaker| + # speaker.discussion.can_participate?(user) + # end + end + end + +end
\ No newline at end of file diff --git a/lib/inboxes/engine.rb b/lib/inboxes/engine.rb index 061694e..4395cde 100644 --- a/lib/inboxes/engine.rb +++ b/lib/inboxes/engine.rb @@ -1,4 +1,9 @@ +require "inboxes/ability" + module Inboxes class Engine < ::Rails::Engine + def self.activate + Ability.register_ability(InboxesAbility) + end end end
\ No newline at end of file |
