whats-wrong 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd032a34c586c27f96fa14cf7d6263c3fc9c0696
|
4
|
+
data.tar.gz: 245c037378081cd69c6720aca0a8c5e43251411a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06a86262a053cab1d61912497bd0d875e65e7464bf96150a4646d4d4f61795360ef63ef169d339115ae620b8b20b4811334c7d6ec86c8ab8bcf947dbc6cc75b0
|
7
|
+
data.tar.gz: 4ba4a9ca05500a91640fb80e961fb5909b344f4d0f7daa39ced49f8b0ea7978bebdb486a30c505dcb05294548f395fe85a6f56003dfd1ce1cc4d9d67aed8cce2
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ gem 'whats-wrong'
|
|
11
11
|
## Usage
|
12
12
|
|
13
13
|
|
14
|
-
#### Generate static pages for your locale
|
14
|
+
#### Solution 1: Generate static pages for your locale
|
15
15
|
|
16
16
|
```ruby
|
17
17
|
rails g whats_wrong:pages zh-CN
|
@@ -23,6 +23,32 @@ rails g whats_wrong:pages zh-CN
|
|
23
23
|
|
24
24
|
Supported locales: en, zh-CN.
|
25
25
|
|
26
|
+
#### Solution 2: or Render with dynamic error pages
|
27
|
+
|
28
|
+
Maybe static pages couldn't fit your necessary. Enable this feature If you want to render error pages with layout.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
rails g whats_wrong:install
|
32
|
+
```
|
33
|
+
|
34
|
+
Then the default error pages will be rendered within your layout.
|
35
|
+
|
36
|
+
|
37
|
+
##### Custom error pages
|
38
|
+
|
39
|
+
Also you can custom error pages(include 404, 422 and 500).
|
40
|
+
|
41
|
+
```html
|
42
|
+
<!-- app/views/exceptions/404.html.erb -->
|
43
|
+
<p>The page you were looking for doesn't exist.</p>
|
44
|
+
|
45
|
+
|
46
|
+
<!-- some helper methods you can use -->
|
47
|
+
<p><%= status %></p> <!-- 404 or others -->
|
48
|
+
<p><%= original_path %></p> <!-- which path case error before render error page -->
|
49
|
+
<p><%= exception %></p><!-- which exception case error -->
|
50
|
+
```
|
51
|
+
|
26
52
|
## Contributing
|
27
53
|
Contribution translations go here https://www.localeapp.com/projects/9397 .
|
28
54
|
|
@@ -1,11 +1,23 @@
|
|
1
1
|
class WhatsWrong::ExceptionsController < ApplicationController
|
2
|
+
# TODO: layout
|
3
|
+
|
4
|
+
helper_method :status, :exception, :original_path
|
2
5
|
|
3
6
|
def show
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
render "exceptions/#{status}", status: status
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
def status
|
12
|
+
@status ||= request.path_info[1..-1].to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
def exception
|
16
|
+
request.env['action_dispatch.exception']
|
17
|
+
end
|
18
|
+
|
19
|
+
def original_path
|
20
|
+
request.env["action_dispatch.original_path"]
|
9
21
|
end
|
10
22
|
|
11
23
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
404 Not Found
|
@@ -0,0 +1 @@
|
|
1
|
+
422 Unprocessable Entity
|
@@ -0,0 +1 @@
|
|
1
|
+
500 Internal Server Error
|
data/lib/whats-wrong/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whats-wrong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bastengao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -49,6 +49,9 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
51
|
- app/controllers/whats_wrong/exceptions_controller.rb
|
52
|
+
- app/views/exceptions/404.html.erb
|
53
|
+
- app/views/exceptions/422.html.erb
|
54
|
+
- app/views/exceptions/500.html.erb
|
52
55
|
- config/locales/en.yml
|
53
56
|
- config/locales/zh-CN.yml
|
54
57
|
- lib/generators/whats_wrong/install_generator.rb
|