1
我的會話控制器軌道4 NoMethodError在SessionsController#創建零未定義的方法`切片」:NilClass
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
我user.rb
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
末 誰能告訴我的事業錯誤我搜索SO相同但無法找到相關解決方案
結束
你有什麼期待您'ENV [「omniauth.auth」]'變量持有... –
您在'auth'上調用'#slice','auth'爲零。你的omniauth哈希值是零。 – depa
我想要我的臉書認證 – Anish