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?
# 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]
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
RailsBaseURI /scala_tour
PassengerPoolIdleTime 5
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.