使用omniauth和自定义用户模型的路由错误

时间:2016-04-10 12:11:28

标签: ruby-on-rails ruby omniauth

我通过Useromniauth-facebook拥有自定义omniauth-vkontakte模型和身份验证。需要进行身份验证才能将评论留给Post模型并查看Book模型。所以我定义了一个sessions_controller.rb

def create
    user = User.from_omniauth(request.env['omniauth.auth'])
    cookies[:user_id] = user.id
    redirect_to root_path
end

以及show.html.erbBook模型的Post我都有以下内容:

<div>
    <p>Only signed in users can leave comments/reviews. 
    Please sign in via <%= link_to 'Facebook', 'auth/facebook' %> or
    <%= link_to 'VK', 'auth/vkontakte' %> </p>
</div> 

routes.rb我有这个:

get 'auth/:provider/callback', to: 'sessions#create'

控制台返回以下错误:ActionController::RoutingError (No route matches [GET] "/books/auth/facebook")

0 个答案:

没有答案