2012-11-30 70 views
0

我使用omniauth-facebook 1.4.1與設計登錄Facebook。有的Facebook登錄與設計

Could not authorize you from Facebook because "Csrf detected". 

錯誤似乎人們通過降級解決這個問題omniauth Facebook的到1.4.0。我嘗試過,但現在有錯誤

The action 'facebook' could not be found for Devise::OmniauthCallbacksController. 

我有途徑

devise_for :users, :controllers => { :omniauth_callbacks => :omniauth_callbacks} 

和omniauth_callbacks是在控制器目錄:

class OmniauthCallbacksController < Devise::OmniauthCallbacksController 
def facebook 
    # You need to implement the method below in your model 
    @user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user) 

    if @user.persisted? 
    flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook" 
    sign_in_and_redirect @user, :event => :authentication 
    else 
    session["devise.facebook_data"] = env["omniauth.auth"] 
    redirect_to new_user_registration_url 
    end 
end 
end 

有什麼建議?

回答

0

哦,我發現這個問題。在route.rb我有一個行代碼

devise_for :users, :controllers => { :registrations => :registrations } 

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks"} 

其覆蓋方法前面,所以它導致

The action 'facebook' could not be found for Devise::OmniauthCallbacksController. 

我評論的第一行,然後它作品。