Rails 3 资源功能中自定义一条路线

发布于 2024-10-02 09:30:32 字数 205 浏览 0 评论 0原文

默认情况下,resources 命令生成 new 操作的 url 作为 {model}/new。根据文档,发送 path_names = {} 哈希不会更改基本 {model}。我将如何将 /submit 路由到 posts#new 操作?

By default the resources command generates the url for new action as {model}/new. Sending a path_names = {} hash doesn't change the base {model} according to the documentation. How would I go about routing /submit to posts#new action?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

<逆流佳人身旁 2024-10-09 09:30:32
match 'submit' => 'posts#new'

我希望这就是您正在寻找的...

如果您想了解它在幕后的工作原理,您可能想看看 Ryan Bates 的两个精彩截屏视频。

路由演练 路由-walkthrough-part-2

match 'submit' => 'posts#new'

I hope this is what you are looking for...

You might want to have a look at those two awesome screencasts by Ryan Bates if you wish to understand how it works behind the scene.

routing-walkthrough routing-walkthrough-part-2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文