You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/lib/tasks/user_login.rake

20 lines
639 B

namespace :user do
task :update_login => :environment do
begin
user_count = ENV['args'].split(",")[0].to_i # 更新的用户数
status = ENV['args'].split(",")[1] # 测试用户类型
base_login = ENV['args'].split(",")[2] # 基本的用户参数
users = User.where(:is_test => status).limit(user_count)
users.each_with_index do |user, i|
puts i
no = sprintf("%04d", i)
login = "#{base_login}#{no}"
user.update_attributes(:login => login, :lastname => login, :nickname => login)
end
rescue Exception => e
Rails.logger.error(e.message)
end
end
end