Rails 3路由-从route.rb传递参数 [英] Rails 3 routing - passing params from routes.rb

查看:136
本文介绍了Rails 3路由-从route.rb传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在rails 2.3.5中,您可以在routes.rb文件中执行以下操作:

In rails 2.3.5 you could do something like this inside the routes.rb file:

map.root :controller => "pages", :action => "show", :id => 3

在rails 3中,我找不到任何传递特定参数的方法(例如在rails 2.3中) .5 with:id => 3)。

In rails 3 I haven't found any way to pass a specific parameter (like in rails 2.3.5 with :id => 3).

我知道我可以从控制器处理它并获得相同的结果(我这样做了),但是我想知道是否有一种方法可以在其中执行相同的操作可以从routes.rb中获取rails 3还是更改它,因为出于某种原因它是更好的做法?

I know I can handle it from the controller and have the same result (which I did), but I was wondering if there is a way to do the same thing in rails 3 from the routes.rb or has it changed because it is better practice for some reason?

推荐答案

您确定以下内容不起作用?

Are you sure the following doesn't work?

root :to => "pages#show", :id => 3

这篇关于Rails 3路由-从route.rb传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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