ruby - Routing with regex condition in Rails 2 -


in routes.rb file, i've defined these routes:

  map.with_options(:controller => "review") |review|     review.review_index    "/review/:page", :action => "index", :defaults => {:page => nil}, :requirements => {:page => /[0-9]./}     review.review_provider "/review/:category_name/:page", :action => "provider", :defaults => {:page => nil}   end 

however, match second routes. example,

/review/1 

must match first rule in fact matched second rule.

how can config that:

/review/1 match first rule /review/a_category/1  match second rule 

your regular expression in first route bad. period matches single character.

/[0-9]/ means "any number, followed other single character".

so, match /review/1a, /review/70, /review/7?, etc,

if want match 1 or more digits, change regular expression to: /[0-9]+/


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -