1

在将 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). 

这是我的用户模型(直接来自教程),错误似乎来自哪里,第 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

会话控制器

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

我没有第二个教程中的咖啡脚本,当我使用它时出现不同的错误。

任何帮助将不胜感激。

4

1 回答 1

0

我将omniauth-facebook gem 降级为“1.4.0”,它运行良好。

于 2014-08-30T04:17:51.800 回答