2012-11-08 71 views
0

我的教程如下:http://railscasts.com/episodes/235-omniauth-part-1?autoplay=trueRails的Omniauth - NoMethodError在AuthenticationsController#创建

我有我自己的登录和退出过程的工作。但是,当我尝试验证Twitter的登录我

NoMethodError在AuthenticationsController#创建

undefined method `authentications' for nil:NilClass 

app/controllers/authentications_controller.rb:8:in `create' 

我的路线是:

match '/auth/:provider/callback', to: 'authentications#create' 

在我的认证控制器,创建方法是:

def create 
    auth = request.env["omniauth.auth"] 
    current_user.authentications.create(:provider => auth[:provider], :uid => auth[:uid]) 
    flash[:notice] = "Success" 
    redirect_to authentications_url 
    end 

我不知道什么是问题:/

这将是伟大的,如果你能帮助我。

谢谢。

回答

相关问题