URL中的Rails点而不是斜线 [英] Rails dot instead of slash in URL

查看:28
本文介绍了URL中的Rails点而不是斜线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 routes.rb 中,我有:

In my routes.rb I have:

get "projects/:category_id" => "projects#index"

当我编写 projects_path(1) 时,生成的 URL 是 /projects.1 而不是 /projects/1.你知道为什么会这样吗?这是rake routes的输出:

When I write projects_path(1) the generated URL is /projects.1 instead of /projects/1. Do you know why this is happening? Here is the output of rake routes:

 GET /projects/:category_id(.:format) projects#index

推荐答案

projects_path 是索引,它只接受一个参数:格式.你想要 project_path(1)

projects_path is the index, which only takes one argument: the format. You want project_path(1)

这篇关于URL中的Rails点而不是斜线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆