On 4 Nov 2005, at 23:19, Eric Anderson wrote:
> I have a routes question. I have the following in my routes.rb:
>
>
> map.business_letter ''business/:category/:letter/:page'',
> :controller => ''business'', :action =>
''index'',
> :category => ''All'', :letter => nil, :page =>
1,
> :requirements => {:letter => /A-Z/, :page => /\d+/}
>
> Perhaps I don''t understand routes but part of my goal was for a
URL
> like:
>
> /business/Real+Estate/E/2
>
> This would mean show all business from the category "Real Estate"
> that starts with "E" on page 2. But category defaults to
"All",
> letter is optional and page defaults to 1. I have used a named
> route so I could simply do
>
> business_letter_url :letter => ''C'', :category =>
''Real Estate''
>
> I would think this would create a URL that looks like:
>
> /business/Real+Estate/C
>
> instead I get:
>
> /business/Real+Estate?letter=C
>
> If I did the following:
>
> business_letter_url :letter => ''G'', :category =>
''All''
>
> it would output:
>
> /business/All/G
>
> instead I get:
>
> /business?letter=G
>
> Any suggestions?
Your A-Z regex will only literally match "A-Z". Here''s a
little
proof via irb:
irb(main):016:0> "A" =~ /A-Z/
=> nil
irb(main):017:0> "A" =~ /[A-Z]/
=> 0
irb(main):018:0> "A-Z" =~ /A-Z/
=> 0
Put brackets around [A-Z] and you should be in business.
Erik