Skip to content

Instantly share code, notes, and snippets.

@jeffpoulton
Created January 6, 2011 19:13
Show Gist options
  • Save jeffpoulton/768385 to your computer and use it in GitHub Desktop.
Save jeffpoulton/768385 to your computer and use it in GitHub Desktop.
Create Devise Admin Rake Task
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
@CharlyJazz
Copy link

thank dude !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment