Created
June 25, 2011 05:36
-
-
Save tjmcewan/1046199 to your computer and use it in GitHub Desktop.
password resetter
This file contains hidden or 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
namespace :db do | |
desc 'Reset all User passwords to "letmein"' | |
task :password_reset => :environment do | |
count = 0 | |
User.all.each do |u| | |
u.password = u.password_confirmation = 'letmein' | |
if u.save | |
count += 1 | |
print '.' | |
else | |
puts 'Error: ' + u | |
end | |
end | |
puts | |
puts 'Total passwords reset: ' + count.to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment