I’ve set up an instance of Tracks recently on a dremhost account that I have and it was working lovely until I tried to use the stats page. For some reason it was coming up with a 404 error. I did some searching on the Tracks forum page and found that other people were having the same problem. After reading through the thread and noticing that Dreamhost use stats as the link to their hosting statistics, it occured to me that all that was needed was to redirect the stats controller to a different path.
Armed with this knowledge, the first part was easy. Adding a line similar to what Reinier Balt suggested would point the controller somewhere else. I came up with this line:
map.statistics 'statistics', :controller => 'stats', :action => 'index'
I then had to restart passenger to pick up the changes. The recommended way is to create or touch a file called tmp/restart.txt. All well and good except there is no tmp directory in Tracks. So after some searching around, I decided to create one. Then after a quick “touch tmp/restart.txt” I reloaded the Tracks index page. Lo and behold, it worked!
The link to the stats page had changed to point to statistics and the page loaded…mostly.
There are 11 flash graphs on the page and all of them were trying to load from the old stats/ path. I tried editing the _graph partial file to point to a controller called statistics but to no avail. I tried to redirect the stats controller using
map.resources :statistics, :controller => 'stats'
Nothing changed.
I then tried
map.resources :stats, :as => 'statistics'
but nothing changed again.
Then I managed to stumble on the answer after reading Rails Routing from the Outside In
map.connect 'statistics/:action', :controller => 'stats', :action =>':action'
What this does is take any link with statistics/moo and points it towards the stats controller and uses moo as the action. After restarting one final time, and reloading the page, voila, statistics with graphs.
So to recap, the fix for a 404 on the stats page on Dreamhost is to add
map.statistics 'statistics', :controller => 'stats', :action => 'index' map.connect 'statistics/:action', :controller => 'stats', :action =>':action'
before line 70 or so
map.resources :recurring_todos,
in config/routes.rb
