form_errors 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +18 -4
- data/lib/form_errors/version.rb +1 -1
- data/lib/form_errors/view_helpers.rb +6 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5a6eb2baccd0c589befc6fb69b6a0a116b50d89
|
4
|
+
data.tar.gz: c854e8f60b28a5c3c04677c511871598be5f3fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fa0b65fa6b571b826689eeb55add741afa6d02a9ce664febceb080d31ed2e900ce56533ec27940c388adefb8698c466fb1f8401b8838c6f01f1fcd0db9257e5
|
7
|
+
data.tar.gz: 65bc8f7b869ba024c56a1b60053b057743bcaa28ad68c7c282e76c6f230abdcc4ca46c4d1578c50f70e884be64dc0294ce4aea79d313912feb2c1b7bb956ff5c
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Form Errors
|
2
2
|
|
3
3
|
Clean up form error reporting in Rails with a nice little view helper.
|
4
4
|
|
@@ -6,15 +6,21 @@ Clean up form error reporting in Rails with a nice little view helper.
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'form_errors'
|
11
|
+
```
|
10
12
|
|
11
13
|
And then execute:
|
12
14
|
|
13
|
-
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
14
18
|
|
15
19
|
Or install it yourself as:
|
16
20
|
|
17
|
-
|
21
|
+
```
|
22
|
+
$ gem install form_errors
|
23
|
+
```
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
@@ -51,6 +57,14 @@ The helper applies the `alert`, `alert-danger`, and `alert-dismissable` classes
|
|
51
57
|
</div>
|
52
58
|
```
|
53
59
|
|
60
|
+
The `h2` message defaults to:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
"#{ pluralize(object.errors.count, "error") } "\
|
64
|
+
"prohibited this #{ object.class.name.underscore.humanize.downcase } "\
|
65
|
+
"from being saved"
|
66
|
+
```
|
67
|
+
|
54
68
|
## Contributing
|
55
69
|
|
56
70
|
1. Fork it ( http://github.com/johnotander/form_errors/fork )
|
data/lib/form_errors/version.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module FormErrors
|
2
2
|
module ViewHelpers
|
3
|
-
def display_errors(object, error_string = nil)
|
3
|
+
def display_errors(object, error_string = nil, html = {})
|
4
4
|
return unless object && object.errors.any?
|
5
5
|
|
6
6
|
<<-HTML
|
7
7
|
<div class="alert alert-danger alert-dismissable">
|
8
8
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
9
|
-
<h2>
|
9
|
+
<h2 class="#{ html.error_string_class }">
|
10
10
|
#{ get_error_string(error_string, object) }
|
11
11
|
</h2>
|
12
|
-
<ul>
|
12
|
+
<ul class="#{ html.error_list_class }">
|
13
13
|
#{ object.errors.full_messages.map do |msg|
|
14
|
-
"<li>#{ msg }</li>"
|
14
|
+
"<li class=\"#{ html.error_list_item_class }\">#{ msg }</li>"
|
15
15
|
end.join }
|
16
16
|
</ul>
|
17
17
|
</div>
|
@@ -23,8 +23,8 @@ module FormErrors
|
|
23
23
|
|
24
24
|
def get_error_string(error_string, object)
|
25
25
|
error_string || "#{ pluralize(object.errors.count, "error") } "\
|
26
|
-
"prohibited this #{ object.class.name.underscore.humanize.downcase }"\
|
27
|
-
"
|
26
|
+
"prohibited this #{ object.class.name.underscore.humanize.downcase } "\
|
27
|
+
"from being saved"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form_errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Otander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,8 +76,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.4.3
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Clean up form error reporting in Rails with a nice little view helper.
|
83
83
|
test_files: []
|
84
|
+
has_rdoc:
|