Rails 3 和布线
我的应用程序中有 3 个控制器 - 人员、注册、信息。 我的网址如下所示(例如):myweb.com/persons/add、myweb.com/persons/list、myweb.com/registrations/new strong>、myweb.com/informations/old、myweb.com/informations/best 等。
我想问你,是否可以有形状的 URL myweb.com/luis、myweb.com/megan 或 myweb.com/paul - 这些名称来自餐桌人员,我想在URL中如此独立地拥有这些名称...
所以我想向您请教,如何做到这一点,这种情况如何解决...
提前谢谢您
I have in my application 3 controllers - persons, registrations, informations.
My URLs looks this (e.g.): myweb.com/persons/add, myweb.com/persons/list, myweb.com/registrations/new, myweb.com/informations/old, myweb.com/informations/best etc.
And I would like to ask you, if is possible to have URL in shape myweb.com/luis, myweb.com/megan or myweb.com/paul -- these names are from table persons and I would like to have these name so independently in URL...
So I would like to ask you about favor, how could this be done, how this situation to solve...
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为如果您探索Routing Rails Guide,您可以找到解决方案。您必须为您的元素创建自定义路由,例如:
但是,我发现您所要求的内容存在问题,因为您可能会在数据库中找到重复的名称,并且网址应该是唯一的;所以你需要相应地过滤它们。
I think you can find the solution if you explore the Routing Rails Guide. You have to make custom routes for your elements like:
However, I see a problem in what you are asking for, because you could find duplicated names in your databases and the urls should be unique; so you need to filter them accordingly.