1

所以我正在尝试将omniauth构建到我的webpapp中:

从 SessionsController 调用 Omni-Auth

class SessionsController < ApplicationController
  def create
    auth = request.env["omniauth.auth"]
    user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)  
    cookies.permanent.signed[:user_id] = user.id
    redirect_to assignment_path
  end
end

然后将用户添加到用户模型中的数据库中

class User < ActiveRecord::Base
  def self.create_with_omniauth(auth)
    create! do |user|
      user.name = auth["user_info"]["name"]
      user.picture = auth["user_info"]["profile_image_url"]
      user.screen_name = auth["user_info"]["screen_name"]
      user.provider = auth["provider"]
      user.uid = auth["uid"]
    end
  end
end

名称、uid 和提供者被添加到数据库中,但不幸的是图片和屏幕名称没有被添加到数据库中。

任何人都可以帮忙吗?

4

1 回答 1

0

问题解决了。

我使用错误的参数访问哈希。

于 2011-02-22T17:43:34.493 回答