updated readme
This commit is contained in:
20
app/models/ability.rb
Normal file
20
app/models/ability.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class Ability
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
user ||= User.new
|
||||
|
||||
can :manage, :all if user.admin?
|
||||
|
||||
can :read, Category, :state => true
|
||||
can :read, Forum, :state => true, :category => { :state => true }
|
||||
can :read, Topic, :forum => { :state => true, :category => { :state => true } }
|
||||
can :read, Post, :topic => { :forum => { :state => true, :category => { :state => true } } }
|
||||
|
||||
can :update, Post, :user_id => user.id
|
||||
can :destroy, [Topic,Post], :user_id => user.id
|
||||
|
||||
can :create, Post unless user.new_record?
|
||||
can :create, Topic unless user.new_record?
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user