From cb8abd09a9158403cc1f69c56c2dfb2b9d6e98ef Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 18 Mar 2016 12:21:37 -0400 Subject: [PATCH] FIX: users with invalid website in profile get 422 error when viewing topics and other routes --- app/models/user_profile.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb index 2dca5c2f109..7137290326c 100644 --- a/app/models/user_profile.rb +++ b/app/models/user_profile.rb @@ -4,7 +4,7 @@ class UserProfile < ActiveRecord::Base WEBSITE_REGEXP = /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,9}(([0-9]{1,5})?\/.*)?$)/ix validates :bio_raw, length: { maximum: 3000 } - validates :website, format: { with: WEBSITE_REGEXP }, allow_blank: true + validates :website, format: { with: WEBSITE_REGEXP }, allow_blank: true, if: Proc.new { |c| c.new_record? || c.website_changed? } validates :user, presence: true before_save :cook after_save :trigger_badges