activemodel 3.1.0.rc1 → 3.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
data/lib/active_model/errors.rb
CHANGED
@@ -248,7 +248,7 @@ module ActiveModel
|
|
248
248
|
#
|
249
249
|
# company = Company.create(:address => '123 First St.')
|
250
250
|
# company.errors.full_messages # =>
|
251
|
-
# ["Name is too short (minimum is 5 characters)", "Name can't be blank", "
|
251
|
+
# ["Name is too short (minimum is 5 characters)", "Name can't be blank", "Email can't be blank"]
|
252
252
|
def full_messages
|
253
253
|
map { |attribute, message|
|
254
254
|
if attribute == :base
|
@@ -30,7 +30,7 @@ module ActiveModel
|
|
30
30
|
# User.find_by_name("david").try(:authenticate, "notright") # => nil
|
31
31
|
# User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user
|
32
32
|
def has_secure_password
|
33
|
-
attr_reader
|
33
|
+
attr_reader :password
|
34
34
|
|
35
35
|
validates_confirmation_of :password
|
36
36
|
validates_presence_of :password_digest
|
@@ -22,13 +22,13 @@ module ActiveModel
|
|
22
22
|
# of +as_json+. If true (the default) +as_json+ will emit a single root
|
23
23
|
# node named after the object's type. For example:
|
24
24
|
#
|
25
|
-
#
|
26
|
-
#
|
25
|
+
# user = User.find(1)
|
26
|
+
# user.as_json
|
27
27
|
# # => { "user": {"id": 1, "name": "Konata Izumi", "age": 16,
|
28
28
|
# "created_at": "2006/08/01", "awesome": true} }
|
29
29
|
#
|
30
30
|
# ActiveRecord::Base.include_root_in_json = false
|
31
|
-
#
|
31
|
+
# user.as_json
|
32
32
|
# # => {"id": 1, "name": "Konata Izumi", "age": 16,
|
33
33
|
# "created_at": "2006/08/01", "awesome": true}
|
34
34
|
#
|
@@ -38,30 +38,30 @@ module ActiveModel
|
|
38
38
|
# Without any +options+, the returned JSON string will include all the model's
|
39
39
|
# attributes. For example:
|
40
40
|
#
|
41
|
-
#
|
42
|
-
#
|
41
|
+
# user = User.find(1)
|
42
|
+
# user.as_json
|
43
43
|
# # => {"id": 1, "name": "Konata Izumi", "age": 16,
|
44
44
|
# "created_at": "2006/08/01", "awesome": true}
|
45
45
|
#
|
46
46
|
# The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the attributes
|
47
47
|
# included, and work similar to the +attributes+ method. For example:
|
48
48
|
#
|
49
|
-
#
|
49
|
+
# user.as_json(:only => [ :id, :name ])
|
50
50
|
# # => {"id": 1, "name": "Konata Izumi"}
|
51
51
|
#
|
52
|
-
#
|
52
|
+
# user.as_json(:except => [ :id, :created_at, :age ])
|
53
53
|
# # => {"name": "Konata Izumi", "awesome": true}
|
54
54
|
#
|
55
55
|
# To include the result of some method calls on the model use <tt>:methods</tt>:
|
56
56
|
#
|
57
|
-
#
|
57
|
+
# user.as_json(:methods => :permalink)
|
58
58
|
# # => {"id": 1, "name": "Konata Izumi", "age": 16,
|
59
59
|
# "created_at": "2006/08/01", "awesome": true,
|
60
60
|
# "permalink": "1-konata-izumi"}
|
61
61
|
#
|
62
62
|
# To include associations use <tt>:include</tt>:
|
63
63
|
#
|
64
|
-
#
|
64
|
+
# user.as_json(:include => :posts)
|
65
65
|
# # => {"id": 1, "name": "Konata Izumi", "age": 16,
|
66
66
|
# "created_at": "2006/08/01", "awesome": true,
|
67
67
|
# "posts": [{"id": 1, "author_id": 1, "title": "Welcome to the weblog"},
|
@@ -69,7 +69,7 @@ module ActiveModel
|
|
69
69
|
#
|
70
70
|
# Second level and higher order associations work as well:
|
71
71
|
#
|
72
|
-
#
|
72
|
+
# user.as_json(:include => { :posts => {
|
73
73
|
# :include => { :comments => {
|
74
74
|
# :only => :body } },
|
75
75
|
# :only => :title } })
|
@@ -139,8 +139,8 @@ module ActiveModel
|
|
139
139
|
# Without any +options+, the returned XML string will include all the model's
|
140
140
|
# attributes. For example:
|
141
141
|
#
|
142
|
-
#
|
143
|
-
#
|
142
|
+
# user = User.find(1)
|
143
|
+
# user.to_xml
|
144
144
|
#
|
145
145
|
# <?xml version="1.0" encoding="UTF-8"?>
|
146
146
|
# <user>
|
@@ -62,14 +62,14 @@ module ActiveModel
|
|
62
62
|
# Validates that the specified attribute matches the length restrictions supplied. Only one option can be used at a time:
|
63
63
|
#
|
64
64
|
# class Person < ActiveRecord::Base
|
65
|
-
# validates_length_of :first_name, :maximum=>30
|
66
|
-
# validates_length_of :last_name, :maximum=>30, :message=>"less than 30 if you don't mind"
|
65
|
+
# validates_length_of :first_name, :maximum => 30
|
66
|
+
# validates_length_of :last_name, :maximum => 30, :message => "less than 30 if you don't mind"
|
67
67
|
# validates_length_of :fax, :in => 7..32, :allow_nil => true
|
68
68
|
# validates_length_of :phone, :in => 7..32, :allow_blank => true
|
69
69
|
# validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name"
|
70
70
|
# validates_length_of :zip_code, :minimum => 5, :too_short => "please enter at least 5 characters"
|
71
71
|
# validates_length_of :smurf_leader, :is => 4, :message => "papa is spelled with 4 characters... don't play me."
|
72
|
-
# validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least 100 words."
|
72
|
+
# validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least 100 words.", :tokenizer => lambda { |str| str.scan(/\w+/) }
|
73
73
|
# end
|
74
74
|
#
|
75
75
|
# Configuration options:
|
data/lib/active_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15424097
|
4
5
|
prerelease: 6
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 2
|
12
|
+
version: 3.1.0.rc2
|
6
13
|
platform: ruby
|
7
14
|
authors:
|
8
15
|
- David Heinemeier Hansson
|
@@ -10,8 +17,7 @@ autorequire:
|
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
19
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
20
|
+
date: 2011-06-07 00:00:00 Z
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
17
23
|
name: activesupport
|
@@ -21,7 +27,14 @@ dependencies:
|
|
21
27
|
requirements:
|
22
28
|
- - "="
|
23
29
|
- !ruby/object:Gem::Version
|
24
|
-
|
30
|
+
hash: 15424097
|
31
|
+
segments:
|
32
|
+
- 3
|
33
|
+
- 1
|
34
|
+
- 0
|
35
|
+
- rc
|
36
|
+
- 2
|
37
|
+
version: 3.1.0.rc2
|
25
38
|
type: :runtime
|
26
39
|
version_requirements: *id001
|
27
40
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +45,11 @@ dependencies:
|
|
32
45
|
requirements:
|
33
46
|
- - ~>
|
34
47
|
- !ruby/object:Gem::Version
|
48
|
+
hash: 7
|
49
|
+
segments:
|
50
|
+
- 3
|
51
|
+
- 0
|
52
|
+
- 0
|
35
53
|
version: 3.0.0
|
36
54
|
type: :runtime
|
37
55
|
version_requirements: *id002
|
@@ -43,7 +61,11 @@ dependencies:
|
|
43
61
|
requirements:
|
44
62
|
- - ~>
|
45
63
|
- !ruby/object:Gem::Version
|
46
|
-
|
64
|
+
hash: 7
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
- 6
|
68
|
+
version: "0.6"
|
47
69
|
type: :runtime
|
48
70
|
version_requirements: *id003
|
49
71
|
- !ruby/object:Gem::Dependency
|
@@ -54,6 +76,11 @@ dependencies:
|
|
54
76
|
requirements:
|
55
77
|
- - ~>
|
56
78
|
- !ruby/object:Gem::Version
|
79
|
+
hash: 3
|
80
|
+
segments:
|
81
|
+
- 2
|
82
|
+
- 1
|
83
|
+
- 4
|
57
84
|
version: 2.1.4
|
58
85
|
type: :runtime
|
59
86
|
version_requirements: *id004
|
@@ -104,7 +131,6 @@ files:
|
|
104
131
|
- lib/active_model/validator.rb
|
105
132
|
- lib/active_model/version.rb
|
106
133
|
- lib/active_model.rb
|
107
|
-
has_rdoc: true
|
108
134
|
homepage: http://www.rubyonrails.org
|
109
135
|
licenses: []
|
110
136
|
|
@@ -118,17 +144,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
144
|
requirements:
|
119
145
|
- - ">="
|
120
146
|
- !ruby/object:Gem::Version
|
147
|
+
hash: 57
|
148
|
+
segments:
|
149
|
+
- 1
|
150
|
+
- 8
|
151
|
+
- 7
|
121
152
|
version: 1.8.7
|
122
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
154
|
none: false
|
124
155
|
requirements:
|
125
156
|
- - ">"
|
126
157
|
- !ruby/object:Gem::Version
|
158
|
+
hash: 25
|
159
|
+
segments:
|
160
|
+
- 1
|
161
|
+
- 3
|
162
|
+
- 1
|
127
163
|
version: 1.3.1
|
128
164
|
requirements: []
|
129
165
|
|
130
166
|
rubyforge_project:
|
131
|
-
rubygems_version: 1.
|
167
|
+
rubygems_version: 1.8.2
|
132
168
|
signing_key:
|
133
169
|
specification_version: 3
|
134
170
|
summary: A toolkit for building modeling frameworks (part of Rails).
|