简体   繁体   中英

How to change /auth/:provider path by omniauth

To remove controller's name I wrote in routes.rb like this.

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

It worked fine, but when I tried to use the path "/auth/:provider/" from omniauth, the first route overwrite omniauth's path.

Omniauth callback url works with following route.

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

I want to also set the path "/auth/:provider/", but I don't know how to write right side of this.

I've read this question and answer, but I couldn't find how to use :setup option.

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

How can I avoid this problem?

Your routes order must be like below

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

So first if find /auth/:provider it pick this route otherwise if fetch your normal route

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM