From 71ce811c7e87b96fef0a630ce51c170df86677ed Mon Sep 17 00:00:00 2001 From: Coleman Date: Wed, 10 Dec 2008 00:25:30 -0600 Subject: [PATCH] better check for facebook id --- app/models/user.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 61ad511..d61fc23 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,7 +9,7 @@ class User < ActiveRecord::Base validates_uniqueness_of :user_name, :if => lambda { |x| x.facebook_id.nil? } validates_format_of :user_name, :with => /[\w_-]+/, :if => lambda { |x| x.facebook_id.nil? } validates_presence_of :facebook_id, :if => lambda { |x| x.user_name.to_s.empty? } - validate :user_name_is_alphanumeric + validate :user_name_is_alphanumeric, :if => lambda { |x| x.facebook_id.nil? } has_many :photos, :dependent => :destroy has_many :votes, :dependent => :destroy, :order => 'votes.photo_id ASC' @@ -41,7 +41,7 @@ class User < ActiveRecord::Base protected def user_name_is_alphanumeric - if self.facebook_id.to_i == 0 and self.user_name.to_s =~ /[^A-Za-z0-9]/ + if self.user_name.to_s =~ /[^A-Za-z0-9]/ self.errors.add(:user_name, 'has illegal characters') end end