To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / db / migrate / 20130110122628_split_documents_permissions.rb @ 1298:4f746d8966dd

History | View | Annotate | Download (767 Bytes)

1 1295:622f24f53b42 Chris
class SplitDocumentsPermissions < ActiveRecord::Migration
2
  def up
3
    # :manage_documents permission split into 3 permissions:
4
    # :add_documents, :edit_documents and :delete_documents
5
    Role.all.each do |role|
6
      if role.has_permission?(:manage_documents)
7
        role.add_permission! :add_documents, :edit_documents, :delete_documents
8
        role.remove_permission! :manage_documents
9
      end
10
    end
11
  end
12
13
  def down
14
    Role.all.each do |role|
15
      if role.has_permission?(:add_documents) ||
16
          role.has_permission?(:edit_documents) ||
17
          role.has_permission?(:delete_documents)
18
        role.remove_permission! :add_documents, :edit_documents, :delete_documents
19
        role.add_permission! :manage_documents
20
      end
21
    end
22
  end
23
end