Browse files

Small updates

  • Loading branch information...
1 parent 1e47500 commit 34c3b41dd011bd7213173f4c857976c7a6be0111 @kirs committed Nov 21, 2011
Showing with 32 additions and 1 deletion.
  1. +3 −1 Gemfile.lock
  2. +29 −0 app/models/ability.rb
View
4 Gemfile.lock
@@ -1,7 +1,8 @@
PATH
remote: /Users/Kir/Sites/gems/inboxes
specs:
- inboxes (0.0.1)
+ inboxes (0.1.2)
+ cancan
haml-rails
GEM
@@ -39,6 +40,7 @@ GEM
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
+ cancan (1.6.7)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
View
29 app/models/ability.rb
@@ -0,0 +1,29 @@
+class Ability
+ include CanCan::Ability
+
+ def initialize(user)
+ # Define abilities for the passed in user here. For example:
+ #
+ # user ||= User.new # guest user (not logged in)
+ # if user.admin?
+ # can :manage, :all
+ # else
+ # can :read, :all
+ # end
+ cannot :index, Discussion
+ #
+ # The first argument to `can` is the action you are giving the user permission to do.
+ # If you pass :manage it will apply to every action. Other common actions here are
+ # :read, :create, :update and :destroy.
+ #
+ # The second argument is the resource the user can perform the action on. If you pass
+ # :all it will apply to every resource. Otherwise pass a Ruby class of the resource.
+ #
+ # The third argument is an optional hash of conditions to further filter the objects.
+ # For example, here the user can only update published articles.
+ #
+ # can :update, Article, :published => true
+ #
+ # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
+ end
+end

0 comments on commit 34c3b41

Please sign in to comment.