2011-10-12 57 views
1

我正在使用OmniAuth gem與我的Rails應用程序來允許用戶將他們的Facebook帳戶添加到應用程序,並且我遵循Ryan Bates的教程,但是我繼續得到這個Rails錯誤。OmniAuth操作控制器錯誤

未定義#

局部變量或方法`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

你的錯誤是在告訴你,你的路由不存在。運行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 
+0

謝謝!這對我非常有幫助。 –

+0

很高興能夠聽到它,請通過選中對勾來接受答案,如果它回答了您的問題 – iwasrobbed