Devise & Custom Rails User URLs

纵然是瞬间 提交于 2019-12-22 12:26:10

问题


I am currently using Rails 3.2.5 with the latest devise gem.

Currently users can access their profile page at... example.com/users/john-doe

I want to remove the users portion of the url, so the url would be example.com/john-doe. Is this possible with devise?

Right now in my routes file I have the following...

devise_for :users, :controllers => {:omniauth_callbacks => 'omniauth_callbacks'}

回答1:


Just add a route for it. You will probably want it to be the last one in the routes file.

Something like:

match '/:user' => "users#show", :as => :user_profile


来源:https://stackoverflow.com/questions/11909319/devise-custom-rails-user-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!