Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails “是什么?”根“;rake路由输出的平均值?_Ruby On Rails_Routes - Fatal编程技术网

Ruby on rails “是什么?”根“;rake路由输出的平均值?

Ruby on rails “是什么?”根“;rake路由输出的平均值?,ruby-on-rails,routes,Ruby On Rails,Routes,当我跑的时候 rake routes 我看到以下情况: POST /articles/:article_id/comments(.:format) {:action=>"create", :controller=>"articles/comments"} 这很有道理。这意味着,如果我向/articles/1234/comments表单的url发出post请求,它将在articles/comments\u controller.rb中运行控制器的创建操作,i

当我跑的时候

rake routes
我看到以下情况:

POST   /articles/:article_id/comments(.:format)           {:action=>"create", :controller=>"articles/comments"}
这很有道理。这意味着,如果我向/articles/1234/comments表单的url发出post请求,它将在articles/comments\u controller.rb中运行控制器的创建操作,id参数设置为1234

但我也看到了这句话:

/article/:id/:action     {:root=>"article", :controller=>"article/article", :title=>"Article"}
我不知道“:root”是什么意思。有人能解释一下吗

编辑:

我使用的是Rails 2.3.18

下面是routes.rb文件中的相关行

#routes.rb
map.connect '/article/:id/:action', :controller => 'article/article', :root => 'article', :title => 'Article'

就像
:title
,它只是另一个键,值被合并到params散列中

From(默认路线和默认参数)

更正式地说,您可以在路由中包含任意参数, 因此:

map.connect':controller/:action/:id',:action=>show',:page=> “仪表板”

这将把:page参数传递给所有传入的 与此路由匹配的请求


它在Rails中没有任何额外的含义。我猜你的应用程序正在使用它制作面包屑或类似的东西。

复制你的路线。嗯,很有趣。请问您使用的是什么版本的rails?