OmniAuth/Rails

编程入门 行业动态 更新时间:2024-10-26 07:31:47
本文介绍了OmniAuth/Rails-当您不期望它时,您有一个nil对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的Rails应用程序中出现以下错误,我不知道如何调试或修复它:

I'm getting the following error in my Rails application and I have no idea how to go about debugging or fixing it:

NoMethodError在 AuthenticationsController#create

NoMethodError in AuthenticationsController#create

当您没有时,您有一个nil对象 期待它!您可能已经预料到 ActiveRecord :: Base的实例.这 评估为nil时发生错误.[]

You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.[]

Rails.root: /Users/phil/Sites/travlrapp 应用程序跟踪|框架跟踪| 完整跟踪

Rails.root: /Users/phil/Sites/travlrapp Application Trace | Framework Trace | Full Trace

app/controllers/authentications_controller.rb:15:in `创建'

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

控制器是这样的:

class AuthenticationsController < ApplicationController def index @authentications = current_user.authentications if current_user end def create omniauth = request.env["omniauth.auth"] unless omniauth redirect_to authentications_url flash[:notice] = "Could not authenticate via #{params['provider']}." end authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid']) if authentication flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, authentication.user) elsif current_user current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'], :token => omniauth['credentials']['token'], :secret => omniauth['credentials']['secret']) flash[:notice] = "Authentication successful." redirect_to authentications_url else user = User.new user.apply_omniauth(omniauth) if user.save flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, user) else session[:omniauth] = omniauth.except('extra') redirect_to new_user_registration_url end end end def destroy @authentication = current_user.authentications.find(params[:id]) @authentication.destroy flash[:notice] = "Successfully destroyed authentication." redirect_to authentications_url end end

OmniAuth以前可以正常工作,然后我将其混搭起来,试图替换为支持flickr的pchilton的叉子.我是通过在gemfile中设置:git =>并尝试重新安装来完成此操作的,但我不确定我是否做对了.

OmniAuth used to work fine, then I mashed it up trying to swap to a fork by pchilton which supported flickr. I did this by setting :git => in the gemfile and trying to reinstall but im not confident I ever did it right.

我现在已经手动删除了所有omniauth和oafoo gem文件,并首先安装了当前的稳定版(0.1.6)和git master副本,但是所有错误都相同.

I have now manually removed all omniauth and oa- foo gem files and installed first the current stable (0.1.6) and the git master copy but all errors are the same.

这里真是一头雾水,我认识的人都不知道是什么问题.

Really at a loss here, nobody I know has any idea what the problem is.

推荐答案

这似乎是在随机修复.走吧!

This seemed to randomly fix itself. Go Rails!

更多推荐

OmniAuth/Rails

本文发布于:2023-11-23 05:11:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620203.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:OmniAuth   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!