Created
May 11, 2009 19:35
-
-
Save mrichman/110130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RAILS_ROOT/lib/tasks/seed.rake | |
begin | |
require 'highline/import' | |
rescue LoadError | |
puts 'HighLine required, please run rake setup first' | |
end | |
namespace :db do | |
desc "Setup Database" | |
task :seed => :environment do | |
pass = ask('Admin Password: ', String) { |q| q.echo = false } | |
email = ask('Admin Email: ', String) | |
u = User.new | |
u.login = 'admin' | |
u.password = pass | |
u.password_confirmation = pass | |
u.first_name = 'Administrative' | |
u.last_name = 'User' | |
u.email = email | |
begin | |
u.save! | |
u.has_role! :admin # THIS CAUSES A FAILURE!! | |
puts "User '#{u.login}' created successfully!" | |
rescue | |
puts "There were problems with creating a user:" | |
puts u.errors.full_messages # THIS PRINTS NOTHING!!! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment