validates-belongs-to 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/Rakefile +5 -1
- data/lib/validates-belongs-to.rb +3 -0
- data/lib/validates-belongs-to/locale/en.yml +4 -0
- data/lib/validates-belongs-to/version.rb +1 -1
- data/test/validates-belongs-to_test.rb +1 -0
- metadata +4 -3
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/spraints/validates-belongs-to.png)](http://travis-ci.org/spraints/validates-belongs-to)
|
2
|
+
|
1
3
|
Rails 3 validation to ensure that two ActiveModel associations are related to each other.
|
2
4
|
|
3
5
|
class JobApplication
|
@@ -6,6 +8,8 @@ Rails 3 validation to ensure that two ActiveModel associations are related to ea
|
|
6
8
|
validates :resume, :belongs_to => :user
|
7
9
|
end
|
8
10
|
|
11
|
+
The validation checks that `job_application.resume.user` is the same as `job_application.user`.
|
12
|
+
|
9
13
|
Installation:
|
10
14
|
|
11
15
|
gem 'validates-belongs-to'
|
data/Rakefile
CHANGED
data/lib/validates-belongs-to.rb
CHANGED
@@ -50,5 +50,6 @@ class ValidatesBelongsToTest < Test::Unit::TestCase
|
|
50
50
|
obj.thing1.thing2 = :thing2
|
51
51
|
obj.thing2 = :other_thing
|
52
52
|
assert !obj.valid?, 'not valid with non-matching related objects'
|
53
|
+
assert_equal ['Thing1 must have the same thing2 as this record'], obj.errors.full_messages, 'error message'
|
53
54
|
end
|
54
55
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates-belongs-to
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Burke
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
51
|
- lib/validates-belongs-to.rb
|
52
|
+
- lib/validates-belongs-to/locale/en.yml
|
52
53
|
- lib/validates-belongs-to/version.rb
|
53
54
|
- test/validates-belongs-to_test.rb
|
54
55
|
- validates-belongs-to.gemspec
|