设计与自定义Rails用户URL [英] Devise & Custom Rails User URLs
本文介绍了设计与自定义Rails用户URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用Rails 3.2.5与最新的设计宝石。
I am currently using Rails 3.2.5 with the latest devise gem.
目前用户可以访问他们的个人资料页面...
example.com/users/john-doe
Currently users can access their profile page at... example.com/users/john-doe
我想删除该网址的用户部分,因此该url将是 example.com/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'}
推荐答案
只需添加一个路由。你可能希望它是路线文件中的最后一个。
Just add a route for it. You will probably want it to be the last one in the routes file.
这样的东西:
match '/:user' => "users#show", :as => :user_profile
这篇关于设计与自定义Rails用户URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文