X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2c342adc0df6b932165b521247201772f4369923..0a210801928a00d02ad8b9df809650004ae60f74:/app/models/user.rb diff --git a/app/models/user.rb b/app/models/user.rb index 8a471586a..d0993f7ee 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -99,7 +99,7 @@ class User < ApplicationRecord validates :display_name, :if => proc { |u| u.display_name_changed? }, :characters => { :url_safe => true }, :whitespace => { :leading => false, :trailing => false } - validate :display_name_cannot_be_user_id_with_other_id + validate :display_name_cannot_be_user_id_with_other_id, :if => proc { |u| u.display_name_changed? } validates :email, :presence => true, :confirmation => true, :characters => true validates :email, :if => proc { |u| u.email_changed? }, :uniqueness => { :case_sensitive => false } @@ -126,7 +126,7 @@ class User < ApplicationRecord after_save :spam_check def display_name_cannot_be_user_id_with_other_id - display_name_changed? && display_name&.match(/^user_(\d+)$/i) do |m| + display_name&.match(/^user_(\d+)$/i) do |m| errors.add :display_name, I18n.t("activerecord.errors.messages.display_name_is_user_n") unless m[1].to_i == id end end