2012-03-13 6 views
0

私はdeviseの公式Wikiに続いて、omniauthを通してfacebookとdeviseを統合しました。facebookが動作しないomniauthの公式Wikiを作成しますか?

facebookのomniauthコールバックから追加データを保存できません。私は文字通りthis guide

上のすべてをコピーし

注ここでの問題は、self.new_with_sessionが呼び出さ決してであるということである私の現在のuser.rb

class User < ActiveRecord::Base 
    # Include default devise modules. Others available are: 
    # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable, 
     :omniauthable 

    # Setup accessible (or protected) attributes for your model 
    attr_accessible :email, :password, :password_confirmation, :remember_me, 
        :fb_raw 

    def self.find_for_facebook_oauth(access_token, signed_in_resource=nil) 
    data = access_token.extra.raw_info 
    if user = User.where(:email => data.email).first 
     user 
    else # Create a user with a stub password. 
     User.create!(:email => data.email, :password => Devise.friendly_token[0,20]) 
    end 
    end 

    def self.new_with_session(params, session) 
    super.tap do |user| 
     if data = session["devise.facebook_data"] && \ 
      session["devise.facebook_data"]["extra"]["raw_info"] 
     # Here you can save all the info you want including networks and education 
     user.email = data["email"] 
     user.fb_raw = data['raw_info'] 
     end 
    end 
    end 

end 

をご覧ください。私はsuper.tabの直前に例外条項を置いて私の仮説を証明しました。

これを回避する人はいますか?

答えて

0

new_with_sessionDeviseRegistrationControllerですので、OmniauthCallbacksControllerにはありませんので、Facebookのログイン中に決して呼び出されないことが普通です。

+0

ありがとうございます!うん、あなたは正しいです – disappearedng

関連する問題