Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ExpoUserToUser
- def self.start_sync
- ExpoUser.find_each do |expo_user|
- if expo_user.has_role? :expo_owner
- ems_user = User.find_by(email: expo_user.email)
- if ems_user.blank?
- # ems_user = User.new(email: expo_user.email, name: expo_user.name, password: expo_user.password, company: expo_user.company, phone: "", country_code:"")
- ems_user = User.find_or_initialize_by(email: expo_user.email)
- # name: expo_user.name, password: expo_user.password, company: expo_user.company, phone: "", country_code:""
- ems_user.name = expo_user.name
- ems_user.password = expo_user.encrypted_password
- ems_user.encrypted_password = expo_user.encrypted_password
- ems_user.company = "empty" unless expo_user.company
- ems_user.phone = "empty"
- ems_user.country_code = "hk"
- expo_user.user = ems_user
- if ems_user.save
- # ems_user.approve!
- ems_user.update status: :active
- end
- end
- end
- end
- end
- def self.print
- ExpoUser.find_each do |expo_user|
- if expo_user.has_role? :expo_owner
- ems_user = User.find_by(email: expo_user.email)
- puts "dashboard user : "
- puts expo_user.email
- if ems_user.blank?
- puts "didnt had EMS user : "
- puts expo_user.email
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment