简体   繁体   English

SessionsController#中的Omniauth ArgumentError创建错误数量的参数(1表示2)Rails 4

[英]Omniauth ArgumentError in SessionsController#create wrong number of arguments (1 for 2) Rails 4

I am following an online tutorial to incorporate facebook omniauth to a sample application before adding it to my ROR application ( http://richonrails.com/articles/facebook-authentication-in-ruby-on-rails and https://coderwall.com/p/bsfitw ) but I am getting a wrong number of arguments error when I visit the "log into from facebook link". 我正在关注在线教程,将Facebook omniauth合并到示例应用程序中,然后再将其添加到我的ROR应用程序中( http://richonrails.com/articles/facebook-authentication-in-ruby-on-railshttps:// coderwall。 com / p / bsfitw ),但是当我访问“从Facebook链接登录”时,出现了错误的参数数量错误。

ArgumentError in SessionsController#create wrong number of arguments (1 for 2). 

Here is my user model (straight from the tutorial) and where the error appears to be coming from, line 3 is highlighted as the source 这是我的用户模型(直接来自本教程),错误似乎出自哪里,第3行突出显示为源

class User < ActiveRecord::Base
 def self.from_omniauth(auth)
  where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
    user.provider = auth.provider
    user.uid = auth.uid
    user.name = auth.info.name
    user.oauth_token = auth.credentials.token
    user.oauth_expires_at = Time.at(auth.credentials.expires_at)
    user.save!
  end
 end
end

SessionsController SessionsController

class SessionsController < ApplicationController
 def create
    user = User.from_omniauth(env["omniauth.auth"])
    session[:user_id] = user.id
    redirect_to root_url
  end

 def destroy
    session[:user_id] = nil
    redirect_to root_url
  end
 end

I don't have the coffee script from the 2nd tutorial in there, I get a different error when I use it. 我那里没有第二篇教程中的coffee脚本,使用时会出现不同的错误。

Any help would be greatly appreciated. 任何帮助将不胜感激。

我将omniauth-facebook gem评级为“ 1.4.0”,并且工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RoR - SessionsController中的ArgumentError#创建错误的参数数量(1表示2) - RoR - ArgumentError in SessionsController#create wrong number of arguments (1 for 2) ActiveAdmin :: Devise :: SessionsController #creore中的ArgumentError - ArgumentError in ActiveAdmin::Devise::SessionsController#create rails 4:Devise :: SessionsController#create中的NoMethodError - rails 4 : NoMethodError in Devise::SessionsController#create Rails:Devise中的NameError :: SessionsController#create - Rails: NameError in Devise::SessionsController#create 错误登录Rails 3“ SessionsController#create中的NameError” - Error Login Rails 3 “NameError in SessionsController#create ” 使用Omniauth Facebook身份验证Railscast 360在SessionsController#create中出现NoMethodError - NoMethodError in SessionsController#create using Omniauth Facebook authentication railscast 360 ArgumentError:错误的参数数量(0表示1)rails 4 - ArgumentError: wrong number of arguments (0 for 1) rails 4 Rails 5 ArgumentError(参数数量错误(1代表0) - Rails 5 ArgumentError (wrong number of arguments (1 for 0) Rails 3 ArgumentError:错误的参数数目(3为1) - Rails 3 ArgumentError: wrong number of arguments (3 for 1) SessionsController#create中的NoMethodError - NoMethodError in SessionsController#create
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM