Permalink
Browse files

preload default group permissions for new groups

  • Loading branch information...
1 parent 7c45cc1 commit 80ea70822babca16502c61240facc8cef754ca2d TekWiz committed Jan 24, 2010
Showing with 6 additions and 1 deletion.
  1. +6 −1 app/models/group.rb
View
@@ -16,6 +16,11 @@ class Group < ActiveRecord::Base
serialize :permissions, Hash
+ def initialize(*args)
+ super(*args)
+
+ self.permissions = self.class.default_group.permissions if new_record?
+ end
def self.default_group
Group.find_by_name('Default')
@@ -24,7 +29,7 @@ def self.default_group
# Returns true if group is the Default group, else false
def default?
( new_record? ? name : name_was ) == 'Default'
- end
+ end
# Return true is the group has a permission for a resource, else false
def permitted?(resource, action)

0 comments on commit 80ea708

Please sign in to comment.