一种Omniauth的Facebook的before_filter? [英] A before_filter for Omniauth Facebook?
本文介绍了一种Omniauth的Facebook的before_filter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关色器件有一个非常容易使用的before_filter在控制器中使用。
For devise there is a very easy to use Before_filter to use in the controllers.
出于某种原因,我不能让这个为Omniauth_facebook宝石工作。我跟着Railscast在Facebook上Omniauth还
For some reason I can't get this to work for the Omniauth_facebook Gem. I followed the Railscast on Facebook Omniauth and also
before_filter :authenticate
def authenticate
redirect_to :login unless User.find_by_provider_and_uid(auth["provider"], auth["uid"])
end
end
但我得到一个错误:
but I get an error:
NameError in PostsController#new
undefined local variable or method `auth' for #<PostsController:0x007f9fbfa7ee58>
有什么想法?
推荐答案
我觉得你是以后在auth变量是request.env [omniauth.auth]
I think the auth variable you're after is request.env["omniauth.auth"]
这篇关于一种Omniauth的Facebook的before_filter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文