Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcusg/dynamic_error_pages
Engine that helps you to generate dynamic error pages with Rails
https://github.com/marcusg/dynamic_error_pages
Last synced: 16 days ago
JSON representation
Engine that helps you to generate dynamic error pages with Rails
- Host: GitHub
- URL: https://github.com/marcusg/dynamic_error_pages
- Owner: marcusg
- License: mit
- Created: 2013-09-30T21:26:29.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-16T08:32:49.000Z (over 10 years ago)
- Last Synced: 2024-12-09T19:34:38.373Z (about 1 month ago)
- Language: Ruby
- Size: 281 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dynamic_error_pages
[![Gem Version](https://badge.fury.io/rb/dynamic_error_pages.png)](http://badge.fury.io/rb/dynamic_error_pages)
[![Build Status](https://travis-ci.org/marcusg/dynamic_error_pages.png?branch=master)](https://travis-ci.org/marcusg/dynamic_error_pages)
[![Code Climate](https://codeclimate.com/github/marcusg/dynamic_error_pages.png)](https://codeclimate.com/github/marcusg/dynamic_error_pages)
[![Dependency Status](https://gemnasium.com/marcusg/dynamic_error_pages.png)](https://gemnasium.com/marcusg/dynamic_error_pages)Engine that helps you to generate dynamic error pages with Rails
## Requirements
```rails >= 3.2```
## What and why
Normally Rails places some static error pages for special error codes (404, 422 and 500) inside the *public* directory.
These files are rendered if an error occures. But these templates are rendered without a layout.
This causes a bad integration into your custom layout.
The ``` dynamic_error_pages ``` gem let you create your own templates which are rendered inside your application layout.## Installation
Add this line to your application's Gemfile:
gem 'dynamic_error_pages'
And then execute:
$ bundle
## Usage
### Include your templates
Just place your custom error templates inside the ``` app/views/dynamic_error_pages/errors ``` folder. The files need to
be named like the returned status code. The ``` 404.html.erb ``` would be used for status code 404 like ```ActiveRecord::RecordNotFound``` would raise for example.If an error is raised and no template for the status code can be found, the engine will fallback to the ```404.html.erb```-template.
### Include the routing
Activate the routes for dynamic error handling in your ```routes.rb```.
```
YourApp::Application.routes.draw do
# ....
dynamic_error_pagesend
```### Custom error handling
You may want to handle the incoming errors in a different way the gem handles this. Just create a subclass of
For example, create a file named ``` errors_controller.rb ``` in ``` app/controllers ```.class ErrorsController < DynamicErrorPages::ErrorsController
skip_before_filter :my_fancy_stuff # change your filters...def show
# do whatever you want...
super
end
endAnd adjust the routes file to support your custom ```errors_controller```
```
DeviseDynamicErrorPages::Application.routes.draw do
# ....
dynamic_error_pages :controller => "errors"end
```## Limitations
At the moment, the gem will allways force :html format in the response.
In future versions, this behaviour will be extended.## TODO
1. Support more formats
2. Write more tests## Run tests
1. ```bundle install```
2. ```rake appraisal```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request