删掉user里的扩展表信息,防止第一次迁移失败

This commit is contained in:
yanxd 2014-07-07 17:24:51 +08:00
parent ab03962e9a
commit 4dbe149b42
1 changed files with 0 additions and 47 deletions

View File

@ -209,10 +209,6 @@ class User < Principal
# ======================================================================
# 集中处理 User 扩展表为空的问题
# 合并 user_score 属性
validate :valid_user_extensions
after_save :save_user_extensions
def extensions
self.user_extensions ||= UserExtensions.new
@ -222,49 +218,6 @@ class User < Principal
self.user_score ||= UserScore.new
end
alias_method :ori_respond_to?, :respond_to?
def respond_to?(m, include_private = false)
flag = false
flag = ori_respond_to? m.to_sym unless flag
flag = UserExtensions.new.respond_to? m.to_sym unless flag
flag = UserScore.new.respond_to? m.to_sym unless flag
flag
end
def method_missing m, *args, &block
if extensions.respond_to? m.to_sym
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
self.extensions.__send__ m.to_sym, *args
end
__send__ "_meta_#{m}".to_sym, *args, &block
elsif user_score_attr.respond_to? m.to_sym
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
self.user_score_attr.__send__ m.to_sym, *args
end
__send__ "_meta_#{m}".to_sym, *args, &block
else
super
end
end
def valid_user_extensions
if !self.extensions.valid?
self.extensions.errors.messages.each do |key, values|
values.each do |value|
self.errors.add key, value
end
end
end
end
def save_user_extensions
self.extensions.save
self.user_score_attr.save
end
# 集中处理 User 扩展表为空的问题 < end
# ======================================================================
#选择项目成员时显示的用户信息文字