Sha256: f682c842277bef92c07b2dc4325891695d8f8df3f9fe6aac4a94318cdb6e147a

Contents?: true

Size: 477 Bytes

Versions: 7

Compression:

Stored size: 477 Bytes

Contents

module DiscoApp::Concerns::User

  extend ActiveSupport::Concern

  included do
    belongs_to :shop

    def self.create_user(shopify_user, shop)
      user = 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

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.17.0 app/models/disco_app/concerns/user.rb
disco_app-0.18.0 app/models/disco_app/concerns/user.rb
disco_app-0.18.2 app/models/disco_app/concerns/user.rb
disco_app-0.18.3 app/models/disco_app/concerns/user.rb
disco_app-0.18.6 app/models/disco_app/concerns/user.rb
disco_app-0.18.4 app/models/disco_app/concerns/user.rb
disco_app-0.18.1 app/models/disco_app/concerns/user.rb