I've spent way too much time trying to replace the default "404" page for this rails app. From what I've learned, the mechanism to trap "url not found" issues changed in Rails >= 3, and may be broken. At least I wasn't able to get custom, dynamic, "404" pages to work.
One thing that *almost* worked was adding a low-priority routing rule to the very bottom of my routes.rb file, that targeted the controller and view for an error page that I created. Doing that did cause my custom "404" page to display, but it also broke the ability of the administrator to log on to the site.
The only suggestion that I found that actually worked 100% was a suggestion to generate a static 404 html file using rake. The following Rakefile uses the curl command to retrieve the markup for my 404 page, and it stores it in /public/404.html. The page is not dynamic, but it's at least more attractive than the default.
task :default do print "Updating 404 page\n" `curl --silent http://localhost:3000/error_404 -o ../public/404.html` end
This solution is adapted from from Tony Edgecombe's stackoverflow answer.
If it is actually possible to trap "url not found" conditions in Rails 3.1.1, please feel free to submit a comment explaining how. Thanks!
Title | Date |
.NET Public-Key (Asymmetric) Cryptography Demo | July 20, 2025 |
Raspberry Pi 3B+ Photo Frame | June 17, 2025 |
EBTCalc (Android) Version 1.53 is now available | May 19, 2024 |
Vault 3 Security Enhancements | October 24, 2023 |
Vault 3 is now available for Apple OSX M2 Mac Computers! | September 18, 2023 |
Vault (for Desktop) Version 0.77 Released | March 26, 2023 |
EBTCalc (Android) Version 1.44 is now available | October 12, 2021 |