realtime-validations 0.2.3 → 0.3.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.
@@ -10,9 +10,10 @@ module RealtimeValidations
|
|
10
10
|
args = identify_args
|
11
11
|
begin
|
12
12
|
field = identify_field
|
13
|
-
rescue
|
13
|
+
rescue RealtimeValidationsExceptions::InvalidData
|
14
|
+
errors = Rails.env.production? ? [] : ['could not identify field']
|
14
15
|
render :json => { :field => params[:field],
|
15
|
-
:errors =>
|
16
|
+
:errors => errors }
|
16
17
|
return
|
17
18
|
end
|
18
19
|
model = retrieve_or_create_model args, params[:model]
|
@@ -35,7 +36,7 @@ module RealtimeValidations
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def identify_field
|
38
|
-
raise
|
39
|
+
raise RealtimeValidationsExceptions::InvalidData unless params[:field] =~ /^[^\[]+\[(\w+)\]$/
|
39
40
|
$1
|
40
41
|
end
|
41
42
|
|
@@ -54,10 +55,16 @@ module RealtimeValidations
|
|
54
55
|
validates = params[:validates]
|
55
56
|
args.each do |key, value|
|
56
57
|
full_key = key.to_s.singularize
|
57
|
-
|
58
|
+
begin
|
59
|
+
model.send "#{full_key}=", value
|
60
|
+
rescue NoMethodError
|
61
|
+
end
|
62
|
+
end
|
63
|
+
begin
|
64
|
+
model.send "#{field}=", value
|
65
|
+
model.send "#{field}_confirmation=", validates if validates
|
66
|
+
rescue NoMethodError
|
58
67
|
end
|
59
|
-
model.send "#{field}=", value
|
60
|
-
model.send "#{field}_confirmation=", validates if validates
|
61
68
|
before_model_validation model if respond_to? :before_model_validation
|
62
69
|
end
|
63
70
|
|
@@ -1,3 +1,7 @@
|
|
1
|
+
// RealtimeValidations will work with this code commented out. You only need to reimplement this
|
2
|
+
// methods if you want to customize the way errors are shown or hidden, or if you need to add more
|
3
|
+
// information to the request sent to the server via customFields (like current session, user...).
|
4
|
+
|
1
5
|
// RealtimeValidations.customFields = function() {
|
2
6
|
// return { };
|
3
7
|
// }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realtime-validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &22279380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *22279380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jquery-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &22278880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.0.19
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *22278880
|
36
36
|
description: Form real time validations for free on Rails applications
|
37
37
|
email:
|
38
38
|
- ereslibre@gmail.com
|
@@ -41,50 +41,51 @@ extensions: []
|
|
41
41
|
extra_rdoc_files: []
|
42
42
|
files:
|
43
43
|
- app/controllers/realtime_validations/validations_controller.rb
|
44
|
-
- config/routes.rb
|
45
44
|
- config/initializers/form_validated_for.rb
|
46
|
-
-
|
45
|
+
- config/initializers/realtime_validations_exceptions.rb
|
46
|
+
- config/routes.rb
|
47
47
|
- lib/realtime-validations/version.rb
|
48
|
+
- lib/tasks/realtime-validations_tasks.rake
|
49
|
+
- lib/realtime-validations.rb
|
48
50
|
- lib/generators/realtime_validations/install_generator.rb
|
49
|
-
- lib/generators/realtime_validations/templates/initializer.rb
|
50
51
|
- lib/generators/realtime_validations/templates/realtime_validations.custom.js
|
51
|
-
- lib/
|
52
|
+
- lib/generators/realtime_validations/templates/initializer.rb
|
53
|
+
- vendor/assets/javascripts/realtime_validations.js
|
52
54
|
- vendor/assets/stylesheets/realtime_validations.css
|
53
55
|
- vendor/assets/images/valid_field.png
|
54
|
-
- vendor/assets/javascripts/realtime_validations.js
|
55
56
|
- MIT-LICENSE
|
56
57
|
- Rakefile
|
57
58
|
- README.rdoc
|
58
59
|
- test/test_helper.rb
|
59
|
-
- test/
|
60
|
-
- test/dummy/
|
61
|
-
- test/dummy/
|
62
|
-
- test/dummy/
|
63
|
-
- test/dummy/config/
|
64
|
-
- test/dummy/config/
|
60
|
+
- test/realtime-validations_test.rb
|
61
|
+
- test/dummy/config/initializers/inflections.rb
|
62
|
+
- test/dummy/config/initializers/secret_token.rb
|
63
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
64
|
+
- test/dummy/config/initializers/mime_types.rb
|
65
|
+
- test/dummy/config/initializers/session_store.rb
|
66
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
65
67
|
- test/dummy/config/environment.rb
|
66
|
-
- test/dummy/config/
|
68
|
+
- test/dummy/config/boot.rb
|
69
|
+
- test/dummy/config/database.yml
|
70
|
+
- test/dummy/config/environments/test.rb
|
67
71
|
- test/dummy/config/environments/production.rb
|
68
72
|
- test/dummy/config/environments/development.rb
|
69
|
-
- test/dummy/config/
|
73
|
+
- test/dummy/config/routes.rb
|
74
|
+
- test/dummy/config/application.rb
|
70
75
|
- test/dummy/config/locales/en.yml
|
71
|
-
- test/dummy/
|
72
|
-
- test/dummy/
|
73
|
-
- test/dummy/
|
74
|
-
- test/dummy/
|
75
|
-
- test/dummy/
|
76
|
-
- test/dummy/
|
77
|
-
- test/dummy/
|
76
|
+
- test/dummy/Rakefile
|
77
|
+
- test/dummy/public/422.html
|
78
|
+
- test/dummy/public/404.html
|
79
|
+
- test/dummy/public/favicon.ico
|
80
|
+
- test/dummy/public/500.html
|
81
|
+
- test/dummy/app/views/layouts/application.html.erb
|
82
|
+
- test/dummy/app/controllers/application_controller.rb
|
83
|
+
- test/dummy/app/helpers/application_helper.rb
|
84
|
+
- test/dummy/app/assets/javascripts/application.js
|
85
|
+
- test/dummy/app/assets/stylesheets/application.css
|
78
86
|
- test/dummy/script/rails
|
79
87
|
- test/dummy/config.ru
|
80
88
|
- test/dummy/README.rdoc
|
81
|
-
- test/dummy/app/assets/stylesheets/application.css
|
82
|
-
- test/dummy/app/assets/javascripts/application.js
|
83
|
-
- test/dummy/app/controllers/application_controller.rb
|
84
|
-
- test/dummy/app/views/layouts/application.html.erb
|
85
|
-
- test/dummy/app/helpers/application_helper.rb
|
86
|
-
- test/dummy/Rakefile
|
87
|
-
- test/realtime-validations_test.rb
|
88
89
|
homepage: https://github.com/ereslibre/realtime-validations/wiki
|
89
90
|
licenses: []
|
90
91
|
post_install_message:
|
@@ -111,32 +112,32 @@ specification_version: 3
|
|
111
112
|
summary: Provides real time validations for free
|
112
113
|
test_files:
|
113
114
|
- test/test_helper.rb
|
114
|
-
- test/
|
115
|
-
- test/dummy/
|
116
|
-
- test/dummy/
|
117
|
-
- test/dummy/
|
118
|
-
- test/dummy/config/
|
119
|
-
- test/dummy/config/
|
115
|
+
- test/realtime-validations_test.rb
|
116
|
+
- test/dummy/config/initializers/inflections.rb
|
117
|
+
- test/dummy/config/initializers/secret_token.rb
|
118
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
119
|
+
- test/dummy/config/initializers/mime_types.rb
|
120
|
+
- test/dummy/config/initializers/session_store.rb
|
121
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
120
122
|
- test/dummy/config/environment.rb
|
121
|
-
- test/dummy/config/
|
123
|
+
- test/dummy/config/boot.rb
|
124
|
+
- test/dummy/config/database.yml
|
125
|
+
- test/dummy/config/environments/test.rb
|
122
126
|
- test/dummy/config/environments/production.rb
|
123
127
|
- test/dummy/config/environments/development.rb
|
124
|
-
- test/dummy/config/
|
128
|
+
- test/dummy/config/routes.rb
|
129
|
+
- test/dummy/config/application.rb
|
125
130
|
- test/dummy/config/locales/en.yml
|
126
|
-
- test/dummy/
|
127
|
-
- test/dummy/
|
128
|
-
- test/dummy/
|
129
|
-
- test/dummy/
|
130
|
-
- test/dummy/
|
131
|
-
- test/dummy/
|
132
|
-
- test/dummy/
|
131
|
+
- test/dummy/Rakefile
|
132
|
+
- test/dummy/public/422.html
|
133
|
+
- test/dummy/public/404.html
|
134
|
+
- test/dummy/public/favicon.ico
|
135
|
+
- test/dummy/public/500.html
|
136
|
+
- test/dummy/app/views/layouts/application.html.erb
|
137
|
+
- test/dummy/app/controllers/application_controller.rb
|
138
|
+
- test/dummy/app/helpers/application_helper.rb
|
139
|
+
- test/dummy/app/assets/javascripts/application.js
|
140
|
+
- test/dummy/app/assets/stylesheets/application.css
|
133
141
|
- test/dummy/script/rails
|
134
142
|
- test/dummy/config.ru
|
135
143
|
- test/dummy/README.rdoc
|
136
|
-
- test/dummy/app/assets/stylesheets/application.css
|
137
|
-
- test/dummy/app/assets/javascripts/application.js
|
138
|
-
- test/dummy/app/controllers/application_controller.rb
|
139
|
-
- test/dummy/app/views/layouts/application.html.erb
|
140
|
-
- test/dummy/app/helpers/application_helper.rb
|
141
|
-
- test/dummy/Rakefile
|
142
|
-
- test/realtime-validations_test.rb
|