在我的用户模型中,我有:validates_uniqueness_of在heroku上失败?
validates_uniqueness_of:fb_uid(我使用Facebook Connect)。
但是,有时候,用户注册时会出现重复行。这真是太糟了。
两条记录的创建时间在100ms以内。我还没有能够确定它是否发生在两个单独的请求中(heroku日志记录很糟糕,只能返回到目前为止,它只发生两次)。
两件事情:
- 有时请求需要一段时间,因为我查询FB API的名称信息,朋友和图片。
- 我使用bigint来存储fb_uid(后端是postgres)。
我还没有能够在dev中复制。
任何想法将不胜感激。
的登入功能
def self.create_from_cookie(fb_cookie, remote_ip = nil)
return nil unless fb_cookie
return nil unless fb_hash = authenticate_cookie(fb_cookie)
uid = fb_hash["uid"].join.to_i
#Make user and set data
fb_user = FacebookUser.new
fb_user.fb_uid = uid
fb_user.fb_authorized = true
fb_user.email_confirmed = true
fb_user.creation_ip = remote_ip
fb_name_data, fb_friends_data, fb_photo_data, fb_photo_ext = fb_user.query_data(fb_hash)
return nil unless fb_name_data
fb_user.set_name(fb_name_data)
fb_user.set_photo(fb_photo_data, fb_photo_ext)
#Save user and friends to the db
return nil unless fb_user.save
fb_user.set_friends(fb_friends_data)
return fb_user
end
你可以发布注册功能吗? – Spyros 2011-03-10 23:35:09
已发布到问题 – Brian 2011-03-10 23:41:03