奇怪的问题——我的一个控制器中的创建操作没有保存属性——查看下面的代码。所有的行都工作到最后 2 行。 theoauth_token
和 theoauth_expires_at
没有被保存。我检查了属性是否正确命名,等等。有趣的是,如果我将倒数第二行更改为:
omniauth['credentials']['token'] ? provider = omniauth['credentials']['token'] : provider = ''
它工作得很好。实际属性oauth_token
和oauth_expires_at
. 然后我尝试创建 2 个新的虚拟属性以查看它是否可以在那里工作 - 不能。似乎之后创建的任何属性oauth_token
都搞砸了。这是迁移问题吗?有任何想法吗?
def create
params[:authorization] ? authorization_route = params[:authorization] : authorization_route = 'no authorization (invalid callback)'
omniauth = request.env["omniauth.auth"]
if omniauth and params[:authorization]
if authorization_route == "facebook"
omniauth['extra']['raw_info']['email'] ? email = omniauth['extra']['raw_info']['email'] : email = ''
omniauth['extra']['raw_info']['name'] ? name = omniauth['extra']['raw_info']['name'] : name = ''
omniauth['extra']['raw_info']['id'] ? uid = omniauth['extra']['raw_info']['id'] : uid = ''
omniauth['provider'] ? provider = omniauth['provider'] : provider = ''
omniauth['credentials']['token'] ? oauth_token = omniauth['credentials']['token'] : oauth_token = ''
omniauth['credentials']['expires_at'] ? oauth_expires_at = Time.at(omniauth['credentials']['expires_at']) : oauth_expires_at = ''
end
end