2010-11-21 93 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