association_validator 0.5.1 → 0.5.2
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/Manifest +2 -0
- data/README.textile +14 -0
- data/README.txt +13 -0
- data/Rakefile +1 -1
- data/association_validator.gemspec +4 -4
- data/lib/association_validator.rb +1 -1
- metadata +9 -3
data/Manifest
CHANGED
data/README.textile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
h1. How to use
|
2
|
+
|
3
|
+
Validate that the id field is a saved record. It will ignore blank fields, so use presence if you need it.
|
4
|
+
validates :from_age_record_id, :presence => true, :association => {:class_name => 'AgeRecord'}
|
5
|
+
validates :user_id, :presence => true, :association => true
|
6
|
+
|
7
|
+
h1. How to install
|
8
|
+
|
9
|
+
Add the following line to your bundle and install.
|
10
|
+
gem 'association_validator'
|
11
|
+
|
12
|
+
h2. Todo
|
13
|
+
|
14
|
+
* Tests
|
data/README.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
=== How to use
|
2
|
+
Validate that the id field is a saved record. It will ignore blank fields, so use presence if you need it.
|
3
|
+
validates :from_age_record_id, :presence => true, :association => {:class_name => 'AgeRecord'}
|
4
|
+
validates :user_id, :presence => true, :association => true
|
5
|
+
You can also set the message using the :message option:
|
6
|
+
validates :user_id, :association => {:message => 'was unretrievable'}
|
7
|
+
|
8
|
+
=== How to install
|
9
|
+
Add the following line to your bundle and install.
|
10
|
+
gem 'association_validator'
|
11
|
+
|
12
|
+
=== Todo
|
13
|
+
* Tests
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('association_validator', '0.5.
|
5
|
+
Echoe.new('association_validator', '0.5.2') do |p|
|
6
6
|
p.description = "Rails 3 assocation validation for id fields"
|
7
7
|
p.url = "http://github.com/TheEmpty"
|
8
8
|
p.author = "Mohammad El-Abid"
|
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{association_validator}
|
5
|
-
s.version = "0.5.
|
5
|
+
s.version = "0.5.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Mohammad El-Abid"]
|
9
9
|
s.date = %q{2011-03-23}
|
10
10
|
s.description = %q{Rails 3 assocation validation for id fields}
|
11
11
|
s.email = %q{mohammad {dot} elabid {at} gmail}
|
12
|
-
s.extra_rdoc_files = ["lib/association_validator.rb"]
|
13
|
-
s.files = ["Manifest", "Rakefile", "association_validator.gemspec", "lib/association_validator.rb"]
|
12
|
+
s.extra_rdoc_files = ["README.textile", "README.txt", "lib/association_validator.rb"]
|
13
|
+
s.files = ["Manifest", "README.textile", "README.txt", "Rakefile", "association_validator.gemspec", "lib/association_validator.rb"]
|
14
14
|
s.homepage = %q{http://github.com/TheEmpty}
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Association_validator"]
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Association_validator", "--main", "README.textile"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{association_validator}
|
18
18
|
s.rubygems_version = %q{1.6.2}
|
@@ -13,7 +13,7 @@ class AssociationValidator < ActiveModel::EachValidator
|
|
13
13
|
begin
|
14
14
|
valid = c.find(value, :select => 'id') # activerecord will raise an exception if it's not found, so we're going to catch it
|
15
15
|
rescue
|
16
|
-
record.errors[attribute] = "is a non existent record" # and report that it doesn't exist
|
16
|
+
record.errors[attribute] = (options[:message] || "is a non existent record") # and report that it doesn't exist
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: association_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
|
-
requirement: &
|
17
|
+
requirement: &27259968 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,15 +22,19 @@ dependencies:
|
|
22
22
|
version: 3.0.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *27259968
|
26
26
|
description: Rails 3 assocation validation for id fields
|
27
27
|
email: mohammad {dot} elabid {at} gmail
|
28
28
|
executables: []
|
29
29
|
extensions: []
|
30
30
|
extra_rdoc_files:
|
31
|
+
- README.textile
|
32
|
+
- README.txt
|
31
33
|
- lib/association_validator.rb
|
32
34
|
files:
|
33
35
|
- Manifest
|
36
|
+
- README.textile
|
37
|
+
- README.txt
|
34
38
|
- Rakefile
|
35
39
|
- association_validator.gemspec
|
36
40
|
- lib/association_validator.rb
|
@@ -43,6 +47,8 @@ rdoc_options:
|
|
43
47
|
- --inline-source
|
44
48
|
- --title
|
45
49
|
- Association_validator
|
50
|
+
- --main
|
51
|
+
- README.textile
|
46
52
|
require_paths:
|
47
53
|
- lib
|
48
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|