Created
January 6, 2011 19:13
-
-
Save jeffpoulton/768385 to your computer and use it in GitHub Desktop.
Create Devise Admin Rake Task
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
include Rails.application.routes.url_helpers | |
begin | |
namespace :admin do | |
task :create => :environment do | |
puts "You will be prompted to enter an email address and password for the new admin" | |
puts "Enter an email address:" | |
email = STDIN.gets | |
puts "Enter a password:" | |
password = STDIN.gets | |
unless email.strip!.blank? || password.strip!.blank? | |
if Admin.create!(:email => email, :password => password) | |
puts "The admin was created successfully. Log in at #{new_admin_session_path}" | |
else | |
puts "Sorry, the admin was not created!" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank dude !