2012-02-21 71 views
1

當我試圖達到http://127.0.0.1:3000/auth/twitter我獲得以下錯誤:Rails3中設計omniauth嘰嘰喳喳配置

Routing Error 
No route matches [GET] "/auth/twitter 

但我可以訪問它 - 「/用戶/認證/嘰嘰喳喳/」但後來我有一個錯誤的回調路徑。

如何使用正確的URL獲得Twitter身份驗證工作 - 「/ auth/twitter」?下面,我發佈了我的應用程序文件。我用Rails3中,設計,Omniauth

這是耙路輸出:

$ rake routes 
     authentications GET /authentications(.:format)    authentications#index 
         POST /authentications(.:format)    authentications#create 
     new_authentication GET /authentications/new(.:format)   authentications#new 
    edit_authentication GET /authentications/:id/edit(.:format) authentications#edit 
      authentication GET /authentications/:id(.:format)   authentications#show 
         PUT /authentications/:id(.:format)   authentications#update 
         DELETE /authentications/:id(.:format)   authentications#destroy 
       home_index GET /home/index(.:format)     home#index 
     new_user_session GET /users/sign_in(.:format)    devise/sessions#new 
      user_session POST /users/sign_in(.:format)    devise/sessions#create 
    destroy_user_session DELETE /users/sign_out(.:format)    devise/sessions#destroy 
    user_omniauth_callback  /users/auth/:action/callback(.:format) devise/omniauth_callbacks#(?-mix:(?!)) 
      user_password POST /users/password(.:format)    devise/passwords#create 
     new_user_password GET /users/password/new(.:format)   devise/passwords#new 
     edit_user_password GET /users/password/edit(.:format)   devise/passwords#edit 
         PUT /users/password(.:format)    devise/passwords#update 
cancel_user_registration GET /users/cancel(.:format)    devise/registrations#cancel 
     user_registration POST /users(.:format)      devise/registrations#create 
    new_user_registration GET /users/sign_up(.:format)    devise/registrations#new 
    edit_user_registration GET /users/edit(.:format)     devise/registrations#edit 
         PUT /users(.:format)      devise/registrations#update 
         DELETE /users(.:format)      devise/registrations#destroy 
     user_confirmation POST /users/confirmation(.:format)   devise/confirmations#create 
    new_user_confirmation GET /users/confirmation/new(.:format)  devise/confirmations#new 
         GET /users/confirmation(.:format)   devise/confirmations#show 
        users GET /users(.:format)      users#index 
         POST /users(.:format)      users#create 
       new_user GET /users/new(.:format)     users#new 
       edit_user GET /users/:id/edit(.:format)    users#edit 
        user GET /users/:id(.:format)     users#show 
         PUT /users/:id(.:format)     users#update 
         DELETE /users/:id(.:format)     users#destroy 
           /auth/:provider/callback(.:format)  authentications#create 
        root  /  

          home#index 

我omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do 
    provider :twitter, '****', '****' 
end 

的Gemfile:

source 'https://rubygems.org' 

gem 'rails', '3.2.1' 

gem 'mysql2' 
gem 'devise' 
gem 'cancan' 
gem 'omniauth' 
gem 'omniauth-twitter' 
gem 'nifty-generators' 

group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 

    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

gem "mocha", :group => :test 

的routes.rb

RaritySoft::Application.routes.draw do 

    resources :authentications 

    get "home/index" 

    devise_for :users 
    resources :users 

    match '/auth/:provider/callback' => 'authentications#create' 

    root :to => 'home#index' 
end 

User.rb

class User < ActiveRecord::Base 

    has_many :authentications 

    # Include default devise modules. Others available are: 
    # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable 
    devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable 

    # Setup accessible (or protected) attributes for your model 
    attr_accessible :email, :password, :password_confirmation, :remember_me 
end 

回答

4

我已刪除:omniauthable和現在的一切工作正常

+0

等待,所以你需要沒有':omniauthable'爲omniauth工作?什麼在..? – ahnbizcad 2014-09-19 19:33:04