views:

305

answers:

2

I have a Rails app deployed to my server under the context scala_tour. When going to the URL, everything works great. However, if the url is encoded to scala%5ftour (which is what SO does, incidentally), I get an error from Rails and/or Passenger.

Passenger seems to recognize the URL and hands it off to my Rails app, but the Rails app complains with:

ActionController::RoutingError (No route matches "/scala%5Ftour" with {:method=>:get}):

Which is quite odd.

Other than putting in a redirect in Apache and deploying my app to a different context, how can I deal with this?

Versions

# yum list installed | grep http
httpd.i386                               2.2.10-2.el5.eapps     installed    
# yum list installed | grep passen
passenger.i386                           2.2.2-1eapps           installed 
# gem list | grep rails
rails (2.3.2, 2.2.2)
# ruby -v
ruby 1.8.6 (2008-06-20 patchlevel 230) [i386-linux]

routes.rb

ActionController::Routing::Routes.draw do |map|
  map.resources :wiki_pages do |wiki_map|
    wiki_map.history 'history', :controller => 'wiki_pages', :action => 'history', :method => 'GET'
    wiki_map.version 'version/:sha1', :controller => 'wiki_pages', :action => 'version', :method => 'GET'
  end
  map.history '/history.:format', :controller => 'wiki_pages', :action => 'wiki_history', :method => 'get'
  map.resources :diagrams, :only => [:index,:new,:destroy,:edit,:show]
  map.logout '/logout', :controller => 'sessions', :action => 'destroy' 
  map.login '/login', :controller => 'sessions', :action => 'new'
  map.resources :users
  map.resource :session
  map.root :controller => 'wiki_pages', :action => 'show', :id => 'MainPage'
end

Apache conf

RailsBaseURI /scala_tour
PassengerPoolIdleTime 5
+1  A: 

Two things come immediately to mind you could use mod_rewrite in apache to normalize the URL or you could use Rack Middleware to rewrite it. Here is a gem that would probably do the trick for you.

triendeau
Currently, I re-rooted the app to `scalatour` and have apache rewriting the url `scala_tour` to `scalatour`. Seems odd that it shouldn't just work, tho. I mean, from a URL perspective, `scala_tour` and `scala%5Ftour` should be the exact same thing.
davetron5000
A: 

What browser are you using? Just ran into this issue the other day in IE/Safari: http://wantnotechno.wordpress.com/2009/11/10/ie-gotcha-1-uri-underscores/. Apparently underscores in a URI has some issues due to legacy specs for older browsers.

Lukas
It was in Firefox and Safari on Mac
davetron5000