app/models/order.rb
# create a dummy user if one doesn't exist and assign user_id
create a dummy user if one doesn't exist and assign user_id
create a dummy user if one doesn ' t exist and assign user_id
def create_user
    return unless user_id.nil?
    u = User.find_by(email: notify_email, domain_id: domain_id)
    if u.nil?
      u = User.create(
          name: shipping_name || "unknown",
          email: notify_email,
          phone: contact_phone,
          status: "Z",
          role_id: Role.find_by(default: true).id,
          domain_id: domain_id,
          password_digest: SecureRandom.hex(8),
          referral_key: SecureRandom.hex(5),
          location: "#{shipping_city}, #{shipping_state}")
    end
    self.user_id = u.id
  end
def create_user return unless user_id . nil? u = User . find_by ( email : notify_email , domain_id : domain_id ) if u . nil? u = User . create ( name : shipping_name || "unknown" , email : notify_email , phone : contact_phone , status : "Z" , role_id : Role . find_by ( default : true ) . id , domain_id : domain_id , password_digest : SecureRandom . hex ( 8 ) , referral_key : SecureRandom . hex ( 5 ) , location : "#{shipping_city}, #{shipping_state}" ) end self . user_id = u . id end
create a dummy user if one doesn't exist and assign user_id
create a dummy user if one doesn ' t exist and assign user_id