summaryrefslogtreecommitdiff
path: root/app/models/permission.rb
diff options
context:
space:
mode:
authorsimon <simon@zagal.local>2009-02-15 19:52:11 +0100
committerhukl <hukl@eight.local>2009-02-15 20:22:51 +0100
commit41abc82e4db97d9d9eb4bab4af95d5550f9516b5 (patch)
treeef2cd2256b9cb36b9ece4944f7b0e8c046e44d3a /app/models/permission.rb
parent874b7af0499fc73313a60debada20134d536a941 (diff)
* permission api on user model
Diffstat (limited to 'app/models/permission.rb')
-rw-r--r--app/models/permission.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/permission.rb b/app/models/permission.rb
index 3914c9c..438538e 100644
--- a/app/models/permission.rb
+++ b/app/models/permission.rb
@@ -1,11 +1,13 @@
1class Permission < ActiveRecord::Base 1class Permission < ActiveRecord::Base
2 # Validations 2 # Validations
3 validates_presence_of :user_id, :node_id, :granted 3 validates_presence_of :user_id, :node_id, :granted
4 validates_inclusion_of :granted, :in => [true, false]
4 5
5 # Associations 6 # Associations
6 belongs_to :user 7 belongs_to :user
7 belongs_to :node 8 belongs_to :node
8 9
9 # Security 10 # Named scopes
10 attr_protected :user_id, :node_id, :granted # Allow no mass assignments 11 named_scope :for_node, lambda { |node| { :conditions => ['node_id = ?', (node.is_a? Node ? node.id : node)] } }
12 named_scope :for_user, lambda { |user| { :conditions => ['user_id = ?', (user.is_a? User ? user.id : user)] } }
11end 13end