我在我的Rails应用程序中使用OmniAuth gem允许用户将他们的Facebook帐户添加到应用程序,我正在关注Ryan Bates的教程,但我继续得到这个Rails错误。
未定义的局部变量或方法`authentications_url'用于#
以下是身份验证的控制器:
class AuthenticationsController < ApplicationController
def index
@authentications = current_user.authentications if current_user
end
def create
auth = request.env["omniauth.auth"]
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'],auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
end
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
flash[:notice] = "Successfully destroyed authentication."
redirect_to authentications_url
end
端
答案 0 :(得分:0)
您的错误告诉您您的路线不存在。在命令提示符处运行rake routes
,看看您是否有authentications
路由
在该剧集的ASCIIcasts版本中,您的config/routes.rb
文件应与此类似:
ProjectManage::Application.routes.draw do |map|
match '/auth/:provider/callback' => 'authentications#create'
devise_for :users
resources :projects
resources :tasks
resources :authentications # <-- This is the one you're missing
root :to => 'projects#index'
end