This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
#!/usr/bin/env ruby |
| 2 |
require File.dirname(__FILE__)+'/../config/environment' |
| 3 |
ActionMailer::Base.raise_delivery_errors = false |
| 4 |
ActionMailer::Base.delivery_method = :test |
| 5 |
|
| 6 |
if User.find_by_is_admin(true) |
| 7 |
puts "You already have an Administrator" |
| 8 |
exit! |
| 9 |
end |
| 10 |
|
| 11 |
puts "Type in Administrator's e-mail: " |
| 12 |
email = gets.strip |
| 13 |
puts "Type in Administrator's password: " |
| 14 |
password = gets.strip |
| 15 |
|
| 16 |
user = User.new :password => password, :password_confirmation => password, :email => email, :terms_of_use => '1' |
| 17 |
user.login = 'admin' |
| 18 |
user.is_admin = true |
| 19 |
if user.save |
| 20 |
user.activate |
| 21 |
puts "Admin user created successfully." |
| 22 |
else |
| 23 |
puts "Failed creating Admin user." |
| 24 |
end |