rapscallion 0.0.9 → 0.0.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa06bd28f1365091b089b92ff92cdf1acd1d1338
4
- data.tar.gz: 4190f2bc25f317f245a380ba4a4c198b849a7eca
3
+ metadata.gz: 5af40b9502879aab2135668af56670f1a4c566bb
4
+ data.tar.gz: 132d602bcbc1de4cb194409f4d7956303f682564
5
5
  SHA512:
6
- metadata.gz: 5267c559e760b5369292e9f03439da45b69c1c5c43d4f5972d8701ee595e7d6cd9ca8181ec0c727fa500074448d75269e672fb67b9ad2c6296381ea4e8c3e966
7
- data.tar.gz: aa85ca22db6cdd28b51cd8bd25cae977710a1b34aca1d388dce6e09b7bc22714dfca2ac32d188cc07f95b5b73feba5f5c034d5b2e3697d29eff875a8db2de526
6
+ metadata.gz: 6b39cdb7c5d94a55f4402cd88f5135242653a47782f85faa539198471b71c72dc36424d432769b281ee2919115151841ed589347521ff34b0385388b58c4a814
7
+ data.tar.gz: 0a4dca65c9001c542c3c65c284433a438a3af2fe6c8629a5cc5586b6108b00c791ff84edde0893e11ca6472613b638f6af69b856b01db77cff44c00d58b6c62a
@@ -57,12 +57,12 @@
57
57
  confirmation fields are special cases, and add the field to confirm for
58
58
  eg password and password_confirmation
59
59
  */
60
- if (attr.match(/.*_confirmation/) !== undefined) {
60
+ if (attr.match(/(.*)_confirmation/) !== undefined) {
61
61
  var confirmation_field = attr.replace('_confirmation', '');
62
62
  var confirmation_value = form.find('#' + klass + "_" + confirmation_field).val();
63
63
  }
64
64
 
65
- validation_data[confirmation_field] = confirmation_value;
65
+ validation_data['confirmation_field'] = confirmation_value;
66
66
 
67
67
  /* existing record? */
68
68
  if (form.data('existing-record') !== undefined) {
@@ -83,6 +83,7 @@
83
83
 
84
84
  /* if no errors present field is valid, add is_valid css class */
85
85
  if (data.length === 0) {
86
+ console.log('is valid');
86
87
  el.removeClass(settings.field_with_error_class).addClass(settings.field_valid_class);
87
88
 
88
89
  /* if error present field is not valid, add has_error class to input, and error messages after input */
@@ -3,38 +3,30 @@ module Rapscallion
3
3
  class ValidationsController < ::ApplicationController
4
4
 
5
5
  eval %[skip_filter #{_process_action_callbacks.select { |c|
6
- [:before, :after, :around].include? c.kind }.collect{|c|
7
- c.filter.inspect}.join(", ")
8
- }]
6
+ [:before, :after, :around].include? c.kind }.collect{|c|
7
+ c.filter.inspect}.join(", ")
8
+ }]
9
9
 
10
10
  def create
11
11
  klass = params[:klass].camelize.constantize
12
-
13
- if params[:existing_record].present?
14
- item = klass.find(params[:existing_record])
15
- else
16
- item = klass.new
17
- end
18
-
12
+ item = params[:existing_record].present? ? klass.find(params[:existing_record]) : klass.new
19
13
  field = params[:attr]
20
14
  value = params[:field_val]
21
15
  item.send("#{field}=", value)
22
16
  item.valid?
23
17
  errors = item.errors[field].uniq
24
-
25
- if !field.match(/_confirmation/).nil?
26
- field_to_confirm_against = field.gsub('_confirmation', '')
27
- x = params[field_to_confirm_against.to_sym]
28
-
29
- errors = ["doesn't match confirmation"] unless value == x
30
- end
31
-
18
+ errors = check_confirmation_field_match(field, value) if !field.match(/_confirmation/).nil?
32
19
  render json: errors.to_json
33
-
34
20
  rescue => e
35
21
  logger.info "ERROR: #{e}"
22
+ end # end create
23
+
24
+ def check_confirmation_field_match(field, value)
25
+ field_to_confirm_against = field.gsub('_confirmation', '')
26
+ value == params['confirmation_field'] ? [] : ["doesn't match confirmation"]
36
27
  end
28
+ private :check_confirmation_field_match
37
29
 
38
- end
30
+ end # end ValidationsController
39
31
 
40
- end
32
+ end # end Rapscallion module
@@ -1,3 +1,3 @@
1
1
  module Rapscallion
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapscallion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gordon Isnor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-10 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails