2012-11-30 73 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. 

我评论的第一行,然后它作品。