custom_error_message 1.1.0.pre3 → 1.1.1
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.
- data/.rvmrc +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +37 -0
- data/LICENSE +2 -2
- data/README.md +34 -0
- data/custom_error_message.gemspec +1 -1
- data/lib/rails/extensions/active_model.rb +1 -1
- data/spec/custom_error_message_spec.rb +1 -2
- metadata +26 -46
- data/README +0 -52
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.2@custom_error_message --create
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (3.0.5)
|
5
|
+
activesupport (= 3.0.5)
|
6
|
+
builder (~> 2.1.2)
|
7
|
+
i18n (~> 0.4)
|
8
|
+
activerecord (3.0.5)
|
9
|
+
activemodel (= 3.0.5)
|
10
|
+
activesupport (= 3.0.5)
|
11
|
+
arel (~> 2.0.2)
|
12
|
+
tzinfo (~> 0.3.23)
|
13
|
+
activesupport (3.0.5)
|
14
|
+
arel (2.0.9)
|
15
|
+
builder (2.1.2)
|
16
|
+
diff-lcs (1.1.2)
|
17
|
+
i18n (0.5.0)
|
18
|
+
rspec (2.5.0)
|
19
|
+
rspec-core (~> 2.5.0)
|
20
|
+
rspec-expectations (~> 2.5.0)
|
21
|
+
rspec-mocks (~> 2.5.0)
|
22
|
+
rspec-core (2.5.1)
|
23
|
+
rspec-expectations (2.5.0)
|
24
|
+
diff-lcs (~> 1.1.2)
|
25
|
+
rspec-mocks (2.5.0)
|
26
|
+
sqlite3 (1.3.3)
|
27
|
+
sqlite3-ruby (1.3.3)
|
28
|
+
sqlite3 (>= 1.3.3)
|
29
|
+
tzinfo (0.3.25)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
activerecord
|
36
|
+
rspec
|
37
|
+
sqlite3-ruby
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2006 David Easley
|
1
|
+
Copyright (c) 2006-2011 David Easley
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Custom Error Message
|
2
|
+
====================
|
3
|
+
|
4
|
+
This plugin gives you the option to not have your custom validation error message
|
5
|
+
prefixed with the attribute name.
|
6
|
+
|
7
|
+
Rails 3 and Ruby 1.9
|
8
|
+
--------------------
|
9
|
+
|
10
|
+
Custom Error Message is Rails 3 and Ruby 1.9 compatible
|
11
|
+
|
12
|
+
Usage
|
13
|
+
-----
|
14
|
+
|
15
|
+
Sometimes generated error messages don't make sense.
|
16
|
+
|
17
|
+
validates_acceptance_of :accepted_terms, :message => 'Please accept the terms of service'
|
18
|
+
|
19
|
+
This generates the error message:
|
20
|
+
|
21
|
+
Accepted terms Please accept the terms of service
|
22
|
+
|
23
|
+
This plugin uses the carat (^) to omit the name of the attribute from error messages:
|
24
|
+
|
25
|
+
validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'
|
26
|
+
|
27
|
+
This now generates:
|
28
|
+
|
29
|
+
Please accept the terms of service
|
30
|
+
|
31
|
+
CREDITS
|
32
|
+
-------
|
33
|
+
|
34
|
+
This plugin was originally written by David Easley (easleydp@gmail.com)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
3
|
require 'active_record'
|
4
|
+
require 'custom_error_message'
|
4
5
|
|
5
6
|
class User < ActiveRecord::Base
|
6
7
|
has_many :user_roles
|
@@ -24,8 +25,6 @@ class UserRole < ActiveRecord::Base
|
|
24
25
|
belongs_to :user
|
25
26
|
end
|
26
27
|
|
27
|
-
require 'custom_error_message'
|
28
|
-
|
29
28
|
describe "error messages" do
|
30
29
|
before do
|
31
30
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
metadata
CHANGED
@@ -1,37 +1,29 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_error_message
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
- pre3
|
11
|
-
version: 1.1.0.pre3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
prerelease:
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
7
|
+
authors:
|
14
8
|
- David Easley
|
15
9
|
- Jeremy Durham
|
16
10
|
autorequire:
|
17
11
|
bindir: bin
|
18
12
|
cert_chain: []
|
19
|
-
|
20
|
-
date: 2010-12-20 00:00:00 -05:00
|
21
|
-
default_executable:
|
13
|
+
date: 2011-10-06 00:00:00.000000000Z
|
22
14
|
dependencies: []
|
23
|
-
|
24
|
-
|
15
|
+
description: This plugin gives you the option to not have your custom validation error
|
16
|
+
message prefixed with the attribute name
|
25
17
|
email: jeremydurham@gmail.com
|
26
18
|
executables: []
|
27
|
-
|
28
19
|
extensions: []
|
29
|
-
|
30
20
|
extra_rdoc_files: []
|
31
|
-
|
32
|
-
|
21
|
+
files:
|
22
|
+
- .rvmrc
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
33
25
|
- LICENSE
|
34
|
-
- README
|
26
|
+
- README.md
|
35
27
|
- Rakefile
|
36
28
|
- custom_error_message.gemspec
|
37
29
|
- init.rb
|
@@ -40,42 +32,30 @@ files:
|
|
40
32
|
- lib/rails/extensions/active_record.rb
|
41
33
|
- spec/custom_error_message_spec.rb
|
42
34
|
- spec/db/schema.rb
|
43
|
-
has_rdoc: true
|
44
35
|
homepage: http://github.com/jeremydurham/custom-err-msg
|
45
36
|
licenses: []
|
46
|
-
|
47
37
|
post_install_message:
|
48
38
|
rdoc_options: []
|
49
|
-
|
50
|
-
require_paths:
|
39
|
+
require_paths:
|
51
40
|
- lib
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
42
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
- 0
|
60
|
-
version: "0"
|
61
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
48
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
segments:
|
68
|
-
- 1
|
69
|
-
- 3
|
70
|
-
- 1
|
71
|
-
version: 1.3.1
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
72
53
|
requirements: []
|
73
|
-
|
74
54
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.
|
55
|
+
rubygems_version: 1.8.6
|
76
56
|
signing_key:
|
77
57
|
specification_version: 3
|
78
58
|
summary: Custom Error Message plugin for Rails
|
79
|
-
test_files:
|
59
|
+
test_files:
|
80
60
|
- spec/custom_error_message_spec.rb
|
81
61
|
- spec/db/schema.rb
|
data/README
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
Custom Error Message
|
2
|
-
====================
|
3
|
-
|
4
|
-
This plugin gives you the option to not have your custom validation error message
|
5
|
-
prefixed with the attribute name. Ordinarily, if you have, say:
|
6
|
-
|
7
|
-
validates_acceptance_of :accepted_terms, :message => 'Please accept the terms of service'
|
8
|
-
|
9
|
-
You'll get the following error message:
|
10
|
-
|
11
|
-
Accepted terms Please accept the terms of service
|
12
|
-
|
13
|
-
This plugin allows you to omit the attribute name for specific messages. All you have to do
|
14
|
-
is begin the message with a '^' character. Example:
|
15
|
-
|
16
|
-
validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'
|
17
|
-
|
18
|
-
Nigel Ramsay added the ability to specify a proc to generate the message.
|
19
|
-
|
20
|
-
validates_presence_of :assessment_answer_option_id,
|
21
|
-
:message => Proc.new { |aa| "#{aa.label} (#{aa.group_label}) is required" }
|
22
|
-
|
23
|
-
which gives an error message like: Rate (Accuracy) is required
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Detail
|
29
|
-
------
|
30
|
-
|
31
|
-
Redefine the ActiveRecord::Errors::full_messages method:
|
32
|
-
Returns all the full error messages in an array. 'Base' messages are handled as usual.
|
33
|
-
Non-base messages are prefixed with the attribute name as usual UNLESS
|
34
|
-
(1) they begin with '^' in which case the attribute name is omitted.
|
35
|
-
E.g. validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'
|
36
|
-
(2) the message is a proc, in which case the proc is invoked on the model object.
|
37
|
-
E.g. validates_presence_of :assessment_answer_option_id,
|
38
|
-
:message => Proc.new { |aa| "#{aa.label} (#{aa.group_label}) is required" }
|
39
|
-
which gives an error message like:
|
40
|
-
Rate (Accuracy) is required
|
41
|
-
|
42
|
-
|
43
|
-
Download
|
44
|
-
--------
|
45
|
-
|
46
|
-
http://rubyforge.org/projects/custom-error-message/
|
47
|
-
|
48
|
-
|
49
|
-
Bugs & feedback
|
50
|
-
---------------
|
51
|
-
|
52
|
-
Please send bug reports, patches and feedback to David Easley at easleydp@gmail.com
|