Rails 3 routing - passing params from routes.rb

梦想的初衷 提交于 2019-12-30 01:45:12

问题


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

map.root :controller => "pages", :action => "show", :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).

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?


回答1:


Are you sure the following doesn't work?

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


来源:https://stackoverflow.com/questions/3533960/rails-3-routing-passing-params-from-routes-rb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!