Sha256: c86c59196bb1cb24a744346191f35104972848e0316f9f2567af1c4f1912fa9f
Contents?: true
Size: 1.28 KB
Versions: 8
Compression:
Stored size: 1.28 KB
Contents
module ZuoraConnect class ZuoraUser < ActiveRecord::Base self.table_name = "zuora_users" attr_accessor :session cattr_accessor :current_user_id, :current_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
8 entries across 8 versions & 1 rubygems