1

だから私は私のwebpappにomniauthを構築しようとしています:

Omni-AuthはSessionsControllerから呼び出されます

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

そして、ユーザーはユーザーモデルのDBに追加されます

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、プロバイダーはDBに追加されますが、残念ながら、pictureとscreen_nameはDBに追加されません。

誰か助けてもらえますか?

4

1 に答える 1

0

問題が解決しました。

間違ったパラメータを使用してハッシュにアクセスしていました。

于 2011-02-22T17:43:34.493 に答える