Show More
Commit Description:
fixed empty main/test bug...
Commit Description:
fixed empty main/test bug
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@90 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
db/migrate/010_add_admin_and_roles.rb
| 38 lines
| 1.0 KiB
| text/x-ruby
| RubyLexer
|
|
r0 | class AddAdminAndRoles < ActiveRecord::Migration | ||
def self.up | ||||
root = User.new(:login => 'root', | ||||
:full_name => 'Administrator', | ||||
:alias => 'root') | ||||
root.password = 'ioionrails'; | ||||
root.encrypt_new_password | ||||
role = Role.create(:name => 'admin') | ||||
root.roles << role; | ||||
root.save | ||||
user_admin_right = Right.create(:name => 'user_admin', | ||||
:controller => 'user_admin', | ||||
:action => 'all') | ||||
problem_admin_right = Right.create(:name=> 'problem_admin', | ||||
:controller => 'problems', | ||||
:action => 'all') | ||||
role.rights << user_admin_right; | ||||
role.rights << problem_admin_right; | ||||
role.save | ||||
end | ||||
def self.down | ||||
admin_role = Role.find_by_name('admin') | ||||
admin_role.destroy unless admin_role==nil | ||||
admin_right = Right.find_by_name('user_admin') | ||||
admin_right.destroy unless admin_right==nil | ||||
admin_right = Right.find_by_name('problem_admin') | ||||
admin_right.destroy unless admin_right==nil | ||||
root = User.find_by_login('root') | ||||
root.destroy unless root==nil | ||||
end | ||||
end | ||||