2010-11-21 14 views
0

J'ai eu cette voie dans mon rails2.x apprails3 + problème de routage

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

qui a dirigé chaque espace de noms après ma racine à un contrôleur appelé « web_page » et à une action appelée « index »

ex: si un type I http://localhost:3000/products il va http://localhost:3000/web_pages/index

si un type I http://localhost:3000/services encore il va http://localhost:3000/web_pages/index

Mais comment puis-je faire en routes rails3

pls aident

merci à l'avance

acclamations

Sameera

Répondre

0

Vous pouvez utiliser:

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

demande à http://example.com/this/is/a/test?option=true devenir:

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

Salut Sinetris, cela a beaucoup fonctionné – sameera207