Overriding Rails default static error pages for your locale.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app Support dynamic error pages Jun 20, 2016
bin first blood Jun 15, 2016
lib Bump 0.2.0 Jun 20, 2016
test first blood Jun 15, 2016
.gitignore Ignore *.gem Jun 16, 2016
Gemfile first blood Jun 15, 2016
Gemfile.lock first blood Jun 15, 2016
MIT-LICENSE first blood Jun 15, 2016
Procfile Generator could gen static pages for specific locale. Jun 16, 2016
README.md Support dynamic error pages Jun 20, 2016
Rakefile first blood Jun 15, 2016
whats-wrong.gemspec New description Jun 15, 2016

README.md

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.