@ -7,6 +7,14 @@ class ApplicationRecord < ::ActiveRecord::Base
saved_change_to_attribute?(:id)
end
##
# Returns whether the given attribute is free of errors
def valid_attribute?(attribute)
valid? # Ensure validations have run
errors[attribute].empty?
# Get the newest recently changed resource for the given record classes
#
@ -42,7 +42,7 @@ module Users
def set_default_attributes(_params)
# Assign values other than mail to new_user when invited
if model.invited? && model.mail.present?
if model.invited? && model.valid_attribute?(:mail)
::UserInvitation.assign_user_attributes model