Sha256: 235cb04920db4a2ee82f060fea11319af2afc3552f87a203181b40d288cf2cc8

Contents?: true

Size: 481 Bytes

Versions: 14

Compression:

Stored size: 481 Bytes

Contents

module DiscoApp::Concerns::User
  extend ActiveSupport::Concern

  included do
    belongs_to :shop

    def self.create_user(shopify_user, shop)
      user = self.find_or_create_by!(id: shopify_user.id, shop: shop)
      user.update(
        first_name: shopify_user.first_name || '',
        last_name: shopify_user.last_name || '',
        email: shopify_user.email
      )
      user
    rescue ActiveRecord::RecordNotUnique, PG::UniqueViolation
      retry
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/models/disco_app/concerns/user.rb
disco_app-0.13.6 app/models/disco_app/concerns/user.rb
disco_app-0.13.7 app/models/disco_app/concerns/user.rb
disco_app-0.13.8 app/models/disco_app/concerns/user.rb
disco_app-0.14.1 app/models/disco_app/concerns/user.rb
disco_app-0.14.2 app/models/disco_app/concerns/user.rb
disco_app-0.15.0 app/models/disco_app/concerns/user.rb
disco_app-0.16.0 app/models/disco_app/concerns/user.rb
disco_app-0.14.4 app/models/disco_app/concerns/user.rb
disco_app-0.14.3 app/models/disco_app/concerns/user.rb
disco_app-0.16.1 app/models/disco_app/concerns/user.rb
disco_app-0.15.2 app/models/disco_app/concerns/user.rb
disco_app-0.14.0 app/models/disco_app/concerns/user.rb
disco_app-0.13.6.pre.puma.pre.3 app/models/disco_app/concerns/user.rb