[英]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-rails和https:// 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.