Route generation problems

Charlie Hubbard wrote:


I have an outstanding problem with route generation. Right now if I
generate a route with the following syntax.

url_for( :controller => "foo", :action => "bar", :id => 4 )

I get


I always get a URL without a trailing slash on the end. I want to add a
trailing slash always after the ID parameter. I have generated HTML
content that I want to always append to the root URL like above. And I
keep getting bad URLS. I also have another problem when doing route
generation where:

url_for( :controller => "foo", :action => "bar", :id => 4, :page => 5 )



Eventhough my route configuration is:

  map.connect "foo/bar/:id/:page",
        :controller => "Foo",
        :action => "bar",
        :requirements => { :id => /\d+/,
                           :page => /(\d+)|(\w+\.html)/ }

This rule is never used when generating routes, and it's really
important because of the problem I showed above.

Any help please?


Hey C,

I guess you already tried the following, but just in case:

  map.connect "foo/bar/:id/:page",
        :controller => "foo",
        :action => "bar",
        :requirements => { :id => /\d+/,
                           :page => /(\d+)|(\w+\.html)/ }

  # I've never had explicit x.html
  # requests routed to rails though
  # so I've no idea if it'll work

  map.connect ":controller/:action/:id/"
  map.connect ":controller/:action/:id"

  # should solve the trailing slash issue

Gustav Paul