Rails Routing Question: Mapping Slugs/Permalinks Directly under Root?

情到浓时终转凉″ 提交于 2019-12-01 12:38:48

You're doing it right. Rails routes go from high priority at the top to low priority at the bottom. Your users show action should go at the bottom. Just make sure that if the permalink does not correspond to a user a proper 404 is generated.

What if you get a user whose username is the same as other URLs on your site? This seems like a trouble waiting to happen.

Just change it to http://www.example.com/user/username

This way you create a "user" namespace for all username based URLs.

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