Rails 4 - would like to make custom error pages in a public folder using I18n

I had my own error pages in a Rails 3.2.13 application using config.exceptions_app = self.routes

in config / application.rb with my logic in errors_controller and views in applications / views / errors. I used the Rails 3 version of the routing filter harness that took care of the routing. I removed the gem because it doesn't work with Rails 4.

I rewrote the routing logic using a built-in Rails function and rewrote the application in Rails 4. Using a native Rails function broke the logic I had for my custom error pages. You can read the details of what I was trying to do to fix Ruby on Rails 3.2.13 logic - Getting errors with custom error pages using I18n . I have done a lot of searches on the internet but I cannot find any information on this. I've found several solutions that supposedly work on websites that haven't been localized. However, I need one for localized websites.

I decided to now try to accomplish this by moving the error pages to a shared folder if possible. Can I just move the html.erb files from applications / views / errors to a shared folder and the pages will find my translations in the locale files? Again, I did a lot of searching on the web, and at this point I have not found any examples of custom error pages for Rails 4 applications using I18n. The Rails manuals don't say anything about errors in a shared folder or elsewhere.

Any help would be appreciated.

+1


source to share


1 answer


After searching the past few days, I decided to try something I read in the Stack Overflow post. The solution provided in How can I use i18n for my error pages in Rails 3? , was introduced in Rails 2.3. Part of the solution was to create an html file for each locale available, such as 404.en.html. 404.fr.html etc. It included adding a file to lib / tasks and other things that were more than I wanted.

I decided to go ahead and create HTML error files for each region without requiring any other recommended stuff. The logic works great.

It looks like it is config.exceptions_app = self.routes

outdated. I cannot say it officially because I have never found any documents that talk about it. I have successfully updated all of my localized Rails applications.



UPDATE 11/8/2013 9:35 AM CST

I posted questions about my problem on other blogs discussing custom error pages in Rails 3. One blog post confirmed that the accessor for exceptions_app was deprecated in Rails 4. Luckily, the custom error page process was simplified in Rails 4. ...

+1


source







All Articles