32 lines
1.0 KiB
Plaintext
32 lines
1.0 KiB
Plaintext
Permission.destroy_all
|
|
|
|
base_actions = ApplicationController.action_methods
|
|
# i should probably figure out all of the children of ApplicationController
|
|
# rather than defining them here.
|
|
controllers = [ PagesController, HelpController, DiscussionsController,
|
|
PeoplesController, BeersController, BreweriesController, RolesController ]
|
|
controllers.each do |c|
|
|
actions = c.action_methods - base_actions
|
|
cname = c.controller_name
|
|
actions.each { |a| Permission.create(:controller => cname, :action => a) }
|
|
end
|
|
|
|
r = Role.base_role
|
|
Permission.find(:all,
|
|
:conditions => [ 'controller = ?', 'pages' ]).each do |p|
|
|
next if [ 'new', 'create', 'edit', 'update', 'destroy' ].include?(p.action)
|
|
r.permissions << p
|
|
end
|
|
Permission.find(:all,
|
|
:conditions => [ 'controller = ?', 'help' ]).each do |p|
|
|
next if [ 'new', 'create', 'edit', 'update', 'destroy' ].include?(p.action)
|
|
r.permissions << p
|
|
end
|
|
|
|
r2 = Role.admin_role
|
|
Permission.find(:all).each do |p|
|
|
r2.permissions << p unless r.permissions.include?(p)
|
|
end
|
|
|
|
puts "All permissions created"
|