summaryrefslogtreecommitdiff
path: root/app/models/permission.rb
blob: 438538e5a436aa51de4d0393afdcbb5688d937c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
class Permission < ActiveRecord::Base
  # Validations
  validates_presence_of   :user_id, :node_id, :granted
  validates_inclusion_of  :granted, :in => [true, false]
  
  # Associations
  belongs_to :user
  belongs_to :node
  
  # Named scopes
  named_scope :for_node, lambda { |node| { :conditions => ['node_id = ?', (node.is_a? Node ? node.id : node)] } }
  named_scope :for_user, lambda { |user| { :conditions => ['user_id = ?', (user.is_a? User ? user.id : user)] } }
end