assigned a user id, does not "appear" to have screwed anything up
This commit is contained in:
@@ -8,6 +8,9 @@ class User < ActiveRecord::Base
|
||||
validates_presence_of :email
|
||||
validates_uniqueness_of :email
|
||||
validates_format_of :email, :with => /.+@.+\..+/i
|
||||
attr_accessor :skip_user_id_assign
|
||||
before_save :assign_user_id, :on => :create
|
||||
|
||||
|
||||
|
||||
def self.authenticate(email, password)
|
||||
@@ -25,5 +28,13 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
return auth
|
||||
end
|
||||
|
||||
def assign_user_id
|
||||
unless @skip_user_id_assign.present?
|
||||
user = User.order("user_id").last
|
||||
uid = user.user_id.to_i + 1 if user && user.user_id && !(User.exists?(:user_id => "#{user.user_id.to_i + 1}"))
|
||||
self.user_id = uid.to_s if uid
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user