0.0
No commit activity in last 3 years
No release in over 3 years
Overriding Rails default static error pages for your locale.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 4
 Project Readme

Whats::Wrong

Overriding Rails default static error pages for your locale.

Installation

Add this line to your application's Gemfile:

gem 'whats-wrong'

Usage

Solution 1: Generate static pages for your locale

rails g whats_wrong:pages zh-CN
# Creating pages for zh-CN ...
#       create  public/404.zh-CN.html
#       create  public/422.zh-CN.html
#       create  public/500.zh-CN.html

Supported locales: en, zh-CN.

Solution 2: or Render with dynamic error pages

Maybe static pages couldn't fit your necessary. Enable this feature If you want to render error pages with layout.

rails g whats_wrong:install

Then the default error pages will be rendered within your layout.

Custom error pages

Also you can custom error pages(include 404, 422 and 500).

<!-- app/views/exceptions/404.html.erb -->
<p>The page you were looking for doesn't exist.</p>


<!-- some helper methods you can use -->
<p><%= status %></p> <!-- 404 or others -->
<p><%= original_path %></p> <!-- which path case error before render error page -->
<p><%= exception %></p><!-- which exception case error -->

Contributing

Contribution translations go here https://www.localeapp.com/projects/9397 .

License

The gem is available as open source under the terms of the MIT License.