2013-05-31 33 views
0

要刪除控制器的名稱,我在routes.rb中這樣寫道。如何通過omniauth更改/ auth /:provider path

get "/:user_id/:id", :to => "words#show", :as => :short_user_word 

它工作得很好,但是當我試圖使用路徑「/ auth /中:供應商/」從omniauth, 第一路線覆蓋omniauth的路徑。

Omniauth回調網址適用於以下路線。

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

我想也設置路徑「/ auth /:provider /」,但我不知道如何寫這個右側。

我讀過這個問題和答案,但我找不到如何使用:安裝選項。

How to change route of omniauth from /auth/:provider to /myapp/auth/:provider

我怎樣才能避免這個問題?

+0

我發現了什麼是錯誤的。如果我在設計中使用omni_auth,我必須使用'/ users/auth /:provider'路徑。 – ironsand

回答

0

你的路線順序必須像下面

get '/auth/:provider/callback' => 'authentications#create' 
get "/:user_id/:id", :to => "words#show", :as => :short_user_word 

所以首先,如果發現/ auth /中:供應商就挑這條路線,否則如果你取正常路線

+0

我使用了錯誤的路徑。不管怎麼說,還是要謝謝你! – ironsand

相關問題