Sha256: 6a7eaa00fc993428ac6026625786e4da463877c065899a50c5dc13b04cfb7bff
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
module ZuoraConnect class ZuoraUser < ActiveRecord::Base self.table_name = "zuora_users" attr_accessor :session cattr_accessor :current_user_id, :current_org_id, :current_org_child_org_ids # zuora_user_id/zuora_entity_id both come from cookie or headers # zuora_current_identity comes from session # app_instance is only needed to try to migrate :/ def self.update_id_response(zuora_user_id, zuora_entity_id, zuora_current_identity, app_instance, permissions) zuora_user = find_or_create_by!(zuora_user_id: zuora_user_id) do |user| user.zuora_identity_response = { zuora_entity_id => zuora_current_identity } user.app_permissions = permissions end zuora_user.zuora_identity_response[zuora_entity_id] = zuora_current_identity zuora_user.app_permissions = permissions if zuora_user.changed? zuora_user.save! end zuora_user # NOTE(hartley): this rescue is deprecated. We should not be migrating in production rescue ActiveRecord::StatementInvalid => e raise unless e.message.include?('PG::UndefinedTable') && e.message.include?('zuora_users') ZuoraConnect.logger.fatal('Error querying zuora_users table: attempting migration to recover') app_instance.apartment_switch(nil, true) retry end end end
Version data entries
4 entries across 4 versions & 1 rubygems