34 lines
		
	
	
		
			407 B
		
	
	
	
		
			Ruby
		
	
	
	
		
		
			
		
	
	
			34 lines
		
	
	
		
			407 B
		
	
	
	
		
			Ruby
		
	
	
	
| 
								 | 
							
								# encoding: utf-8 
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace :member_user_id do
							 | 
						||
| 
								 | 
							
								  task :member_user_id_copy => :environment do
							 | 
						||
| 
								 | 
							
									
							 | 
						||
| 
								 | 
							
								    puts 'start'
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @users = User.all
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @users.each do |user|
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      if user.user_id.blank?
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        @ids = []
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        @ids = user.email.split("@")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        user.user_id = @ids[0]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        user.save
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      else
							 | 
						||
| 
								 | 
							
								        puts 'no data'
							 | 
						||
| 
								 | 
							
								      end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    puts 'end'
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    puts @users.count
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								end
							 |