cirandas.net

ref: master

db/migrate/20120718145131_add_manage_environment_templates_to_admin_role.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
class AddManageEnvironmentTemplatesToAdminRole < ActiveRecord::Migration
  def self.up
    Environment.all.map(&:id).each do |id|
      role = Environment::Roles.admin(id)
      role.permissions << 'manage_environment_templates'
      role.save!
    end
  end

  def self.down
    Environment.all.map(&:id).each do |id|
      role = Environment::Roles.admin(id)
      role.permissions -= ['manage_environment_templates']
      role.save!
    end
  end
end