2010-11-21 95 views
0

我在rails2.x应用了这条路线Rails3中+路由问题

map.with_options(:controller => "web_page") do |site| 
    site.connect "*url", :action => "index" 
end 

它指示每一个命名空间我的根到控制器称为“web_page”后,并称为“索引”

行动例如:如果我型http://localhost:3000/products 它去http://localhost:3000/web_pages/index

如果我型http://localhost:3000/services 仍然不言而喻http://localhost:3000/web_pages/index

但我怎么能做到这一点在Rails3中路线

请事先帮助

感谢

欢呼

sameera

回答

0

您可以使用:

match '/:all' => 'web_page#index', :constraints => { :all => /.+/ } 

请求 http://example.com/this/is/a/test?option=true成为:

class WebPageController < ApplicationController 
    def index 
    @all = params[:all] # "this/is/a/test" 
    @path = request.path # "/this/is/a/test" 
    @query = request.query_parameters # {"option"=>"true"} 
    end 
end 
+0

嗨Sinetris,它的工作非常感谢 – sameera207 2010-11-22 16:08:00