开发者

Rails 3 Routing problem

I convert the Rails-2 application into Rails-3. In my Rails-2 routing i have the routes like the below

Rails 2

map.connect 'example/:action/:id.:format', :controller => 'Test',:q =>'example-string'

Note: This is working well in Rails-2 application; when the url comes with /example it redirect to Test controller's index action with the parameter q="example-string"

I converted the above to support Rails-3 routes:

match 'example(/:action(/:id.(:format)))',:to => 'Test',:q=>'example-stirng'
开发者_StackOverflow社区

The problem is I got the Routing Error /example not found.

How can i change the Rails-2 routes into Rails-3 routes?


You almost got it right. Should be

match 'example(/:action(/:id.(:format)))',:controller => :test, :q=>'example-stirng'

:to => "foo#bar" is a shortcut for :controller => :foo, :action => :bar

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜